Fix void-variable: lua-lsp-dir
And refactor Lua->LSP/eglot integration.
This commit is contained in:
parent
091635d589
commit
25008382c2
2 changed files with 20 additions and 33 deletions
|
@ -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)))
|
|
@ -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!)))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue