From 25008382c2e5a4e03bf2f9900e0b929b3e7a94ac Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 23 Jul 2020 20:21:44 -0400 Subject: [PATCH] Fix void-variable: lua-lsp-dir And refactor Lua->LSP/eglot integration. --- modules/lang/lua/+lsp-mode.el | 18 ------------------ modules/lang/lua/config.el | 35 ++++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 33 deletions(-) delete mode 100644 modules/lang/lua/+lsp-mode.el diff --git a/modules/lang/lua/+lsp-mode.el b/modules/lang/lua/+lsp-mode.el deleted file mode 100644 index b8c98e9b3..000000000 --- a/modules/lang/lua/+lsp-mode.el +++ /dev/null @@ -1,18 +0,0 @@ -;;; lang/lua/+lsp-mode.el -*- lexical-binding: t; -*- - -(defun lsp-lua-langserver--lsp-command () - "Generate LSP startup command." - (list (doom-path lua-lsp-dir - (cond (IS-MAC "bin/macOS") - (IS-LINUX "bin/Linux") - (IS-WINDOWS "bin/Windows")) - "lua-language-server") - "-E" "-e" "LANG=en" - (doom-path lua-lsp-dir "main.lua"))) - -(after! lsp-mode - (lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection 'lsp-lua-langserver--lsp-command) - :major-modes '(lua-mode) - :priority -1 - :server-id 'lua-langserver))) diff --git a/modules/lang/lua/config.el b/modules/lang/lua/config.el index 34a026656..e5cf0fe31 100644 --- a/modules/lang/lua/config.el +++ b/modules/lang/lua/config.el @@ -24,22 +24,27 @@ lua-language-server.") (set-repl-handler! 'lua-mode #'+lua/open-repl) (set-company-backend! 'lua-mode '(company-lua company-yasnippet)) - (set-eglot-client! - 'lua-mode - ;; 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 variable changed - (list (doom-path lua-lsp-dir - (cond (IS-MAC "bin/macOS") - (IS-LINUX "bin/Linux") - (IS-WINDOWS "bin/Windows")) - "lua-language-server") - "-E" "-e" "LANG=en" - (doom-path lua-lsp-dir "main.lua"))) - (when (featurep! +lsp) - (unless (featurep! :tools lsp +eglot) - (load! "+lsp-mode")) + (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 (doom-path +lua-lsp-dir + (cond (IS-MAC "bin/macOS") + (IS-LINUX "bin/Linux") + (IS-WINDOWS "bin/Windows")) + "lua-language-server") + "-E" "-e" "LANG=en" + (doom-path +lua-lsp-dir "main.lua"))) + + (if (featurep! :tools lsp +eglot) + (set-eglot-client! 'lua-mode (+lua-generate-lsp-server-command)) + (after! lsp-mode + (lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection '+lua-generate-lsp-server-command) + :major-modes '(lua-mode) + :priority -1 + :server-id 'lua-langserver)))) (add-hook 'lua-mode-local-vars-hook #'lsp!)))