Skip to content

Commit 30273a4

Browse files
author
lin.sun
authored
[lsp-lua] Support auto downloading and installing "lua-language-server" (#2651)
Support downloading the "lua-language-server" from VSCode extension site.
1 parent c80f44a commit 30273a4

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

clients/lsp-lua.el

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,22 @@
9494
:risky t
9595
:type 'directory)
9696

97-
(defcustom lsp-clients-lua-language-server-bin (f-join lsp-clients-lua-language-server-install-dir "bin/Linux/lua-language-server")
97+
(defcustom lsp-clients-lua-language-server-bin
98+
(f-join lsp-clients-lua-language-server-install-dir
99+
"extension/server/bin/"
100+
(pcase system-type
101+
('gnu/linux "Linux/lua-language-server")
102+
('darwin "macOS/lua-language-server")
103+
('windows-nt "Windows/lua-language-server.exe")))
98104
"Location of Lua Language Server."
99105
:group 'lsp-lua-language-server
100106
:version "7.1"
101107
:risky t
102108
:type 'file)
103109

104-
(defcustom lsp-clients-lua-language-server-main-location (f-join lsp-clients-lua-language-server-install-dir "main.lua")
110+
(defcustom lsp-clients-lua-language-server-main-location
111+
(f-join lsp-clients-lua-language-server-install-dir
112+
"extension/server/main.lua")
105113
"Location of Lua Language Server main.lua."
106114
:group 'lsp-lua-language-server
107115
:version "7.1"
@@ -370,6 +378,20 @@ and `../lib` ,exclude `../lib/temp`.
370378
("Lua.completion.callSnippet" lsp-lua-completion-call-snippet)
371379
("Lua.color.mode" lsp-lua-color-mode)))
372380

381+
(defun lsp-lua-language-server-install (client callback error-callback update?)
382+
"Download the latest version of lua-language-server and extract it to
383+
`lsp-lua-language-server-install-dir'."
384+
(ignore client update?)
385+
(let ((store-path (expand-file-name "vs-lua" lsp-clients-lua-language-server-install-dir)))
386+
(lsp-download-install
387+
(lambda (&rest _)
388+
(set-file-modes lsp-clients-lua-language-server-bin #o0700)
389+
(funcall callback))
390+
error-callback
391+
:url (lsp-vscode-extension-url "sumneko" "lua" "1.17.0")
392+
:store-path store-path
393+
:decompress :zip)))
394+
373395
(lsp-register-client
374396
(make-lsp-client
375397
:new-connection (lsp-stdio-connection (lambda () (or lsp-clients-lua-language-server-command
@@ -379,7 +401,8 @@ and `../lib` ,exclude `../lib/temp`.
379401
#'lsp-clients-lua-language-server-test)
380402
:major-modes '(lua-mode)
381403
:priority -2
382-
:server-id 'lua-language-server))
404+
:server-id 'lua-language-server
405+
:download-server-fn #'lsp-lua-language-server-install))
383406

384407

385408
;;; lua-lsp

0 commit comments

Comments
 (0)