Fix void-variable: lua-lsp-dir

And refactor Lua->LSP/eglot integration.
This commit is contained in:
Henrik Lissner 2020-07-23 20:21:44 -04:00
parent 091635d589
commit 25008382c2
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 20 additions and 33 deletions

View file

@ -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)))

View file

@ -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
(when (featurep! +lsp)
(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")))
(doom-path +lua-lsp-dir "main.lua")))
(when (featurep! +lsp)
(unless (featurep! :tools lsp +eglot)
(load! "+lsp-mode"))
(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!)))