From f002424106f3e273022ccbc4768f73cf56342ca7 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 7 May 2025 23:42:49 -0400 Subject: [PATCH] feat(lua): add treesit support --- modules/lang/lua/autoload/lua.el | 21 ++++++++++++ modules/lang/lua/config.el | 52 ++++++++++++++--------------- modules/lang/lua/doctor.el | 13 ++++++++ modules/tools/tree-sitter/config.el | 1 - 4 files changed, 60 insertions(+), 27 deletions(-) create mode 100644 modules/lang/lua/doctor.el diff --git a/modules/lang/lua/autoload/lua.el b/modules/lang/lua/autoload/lua.el index fb10215e8..e5e19b2c1 100644 --- a/modules/lang/lua/autoload/lua.el +++ b/modules/lang/lua/autoload/lua.el @@ -1,5 +1,26 @@ ;;; lang/lua/autoload/lua.el -*- lexical-binding: t; -*- +;;;###autoload +(defvar +lua-lsp-dir (concat doom-data-dir "lsp/lua-language-server/") + "Absolute path to the directory of sumneko's lua-language-server. + +This directory MUST contain the 'main.lua' file and be the in-source build of +lua-language-server.") + +;;;###autoload +(defun +lua-generate-lsp-server-command () + ;; The absolute path to lua-language-server binary is necessary because the + ;; bundled dependencies aren't found otherwise. The only reason this is a + ;; function is to dynamically change when/if `+lua-lsp-dir' does + (list (or (executable-find "lua-language-server") + (doom-path +lua-lsp-dir + (cond ((featurep :system 'macos) "bin/macOS") + ((featurep :system 'linux) "bin/Linux") + ((featurep :system 'windows) "bin/Windows")) + "lua-language-server")) + "-E" "-e" "LANG=en" + (doom-path +lua-lsp-dir "main.lua"))) + (defun +lua-love-build-command () (when-let (root (+lua-love-project-root)) (format "%s %s" diff --git a/modules/lang/lua/config.el b/modules/lang/lua/config.el index cb59dd905..91d95c307 100644 --- a/modules/lang/lua/config.el +++ b/modules/lang/lua/config.el @@ -8,10 +8,11 @@ ;;; Major modes (use-package! lua-mode - :defer t + :interpreter "\\