Skip to content

Commit 3422c85

Browse files
authored
fix: Improve a few server installations (#4388)
1 parent 193c714 commit 3422c85

File tree

4 files changed

+130
-188
lines changed

4 files changed

+130
-188
lines changed

clients/lsp-actionscript.el

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,13 @@ See https://github.com/BowlerHatLLC/vscode-as3mxml/wiki/Choose-an-ActionScript-S
7878
:group 'lsp-actionscript
7979
:package-version '(lsp-mode . "8.0.0"))
8080

81-
(defun lsp-actionscript--extension-root ()
82-
"The path that the downloaded extension will extract to."
83-
(f-join lsp-actionscript-server-store-path
84-
(format "vscode-nextgenas-%s" lsp-actionscript-version)))
85-
8681
(defun lsp-actionscript--extension-path ()
8782
"Return full path of the downloaded extension."
8883
(f-join lsp-actionscript-server-store-path lsp-actionscript-extension-name))
8984

9085
(defun lsp-actionscript--extension-dir ()
9186
"Return as3mxml extension path."
92-
(f-join (lsp-actionscript--extension-root) "extension"))
87+
(f-join lsp-actionscript-server-store-path "extension"))
9388

9489
(defun lsp-actionscript--server-command ()
9590
"Startup command for ActionScript language server."
@@ -101,33 +96,24 @@ See https://github.com/BowlerHatLLC/vscode-as3mxml/wiki/Choose-an-ActionScript-S
10196
(lsp-actionscript--extension-dir) (lsp-actionscript--extension-dir))
10297
"com.as3mxml.vscode.Main"))
10398

104-
(defun lsp-actionscript--extension-path-zip ()
105-
"Change extension path from .vsix to .zip."
106-
(concat (f-no-ext (lsp-actionscript--extension-path)) ".zip"))
107-
10899
(lsp-dependency
109100
'as3mxml
110101
'(:system "as3mxml")
111102
`(:download :url lsp-actionscript-server-download-url
112-
:store-path ,(lsp-actionscript--extension-path-zip)))
103+
:decompress :zip
104+
:store-path ,(f-no-ext (lsp-actionscript--extension-path))
105+
:set-executable? t))
113106

114107
(lsp-register-client
115108
(make-lsp-client
116109
:new-connection (lsp-stdio-connection
117110
#'lsp-actionscript--server-command
118-
(lambda () (f-exists? (lsp-actionscript--extension-path-zip))))
111+
(lambda () (f-exists? (lsp-actionscript--extension-dir))))
119112
:major-modes '(actionscript-mode)
120113
:priority -1
121114
:server-id 'as3mxml-ls
122115
:download-server-fn (lambda (_client callback error-callback _update?)
123-
(lsp-package-ensure
124-
'as3mxml
125-
(lambda ()
126-
;; TODO: Error handling when unzip failed
127-
(lsp-unzip (lsp-actionscript--extension-path-zip)
128-
(lsp-actionscript--extension-root))
129-
(funcall callback))
130-
error-callback))))
116+
(lsp-package-ensure 'as3mxml callback error-callback))))
131117

132118
(lsp-consistency-check lsp-actionscript)
133119

clients/lsp-cobol.el

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -97,39 +97,23 @@ This is only for development use."
9797
(format lsp-cobol-download-url-format
9898
version "linux" arch version "")))))
9999

100-
(defvar lsp-cobol--server-download-url (lsp-cobol--server-url)
101-
"The actual url used to download language server.")
102-
103-
(defvar lsp-cobol--downloaded-file (f-join lsp-cobol-server-store-path "temp.tar")
104-
"The full file path after downloading the server zipped file.")
105-
106-
(defun lsp-cobol--extract-compressed-file (callback)
107-
"Install COBOL language service."
108-
(cond ((file-exists-p lsp-cobol--downloaded-file)
109-
;; Suprisingly, you can just use `tar' to unzip a zip file on Windows.
110-
;; Therefore, just use the same command.
111-
(lsp-cobol--execute "tar" "-xvzf" lsp-cobol--downloaded-file "-C" lsp-cobol-server-store-path)
112-
;; Delete the zip file.
113-
(ignore-errors (delete-file lsp-cobol--downloaded-file)))
114-
(t
115-
(error "Can't extract the downloaded file: %s" lsp-cobol--downloaded-file)))
116-
(funcall callback))
117-
118100
(defun lsp-cobol--stored-executable ()
119101
"Return the stored COBOL language service executable."
120-
(executable-find
121-
(f-join lsp-cobol-server-store-path
122-
(concat "extension/server/native/"
123-
(cl-case system-type
124-
((cygwin windows-nt ms-dos) "engine.exe")
125-
(darwin "server-mac")
126-
(gnu/linux "server-linux"))))))
102+
(f-join lsp-cobol-server-store-path
103+
(concat "extension/server/native/"
104+
(cl-case system-type
105+
((cygwin windows-nt ms-dos) "engine.exe")
106+
(darwin "server-mac")
107+
(gnu/linux "server-linux")))))
127108

128109
(lsp-dependency
129110
'cobol-ls
130111
'(:system "cobol-ls")
131-
`(:download :url ,lsp-cobol--server-download-url
132-
:store-path ,lsp-cobol--downloaded-file))
112+
`(:download :url ,(lsp-cobol--server-url)
113+
:decompress :zip
114+
:store-path ,(f-join lsp-cobol-server-store-path "temp")
115+
:set-executable? t)
116+
`(:system ,(lsp-cobol--stored-executable)))
133117

134118
;;
135119
;;; Server
@@ -181,9 +165,7 @@ This is only for development use."
181165
:server-id 'cobol-ls
182166
:download-server-fn
183167
(lambda (_client callback error-callback _update?)
184-
(lsp-package-ensure 'cobol-ls
185-
(lambda () (lsp-cobol--extract-compressed-file callback))
186-
error-callback))))
168+
(lsp-package-ensure 'cobol-ls callback error-callback))))
187169

188170
(lsp-consistency-check lsp-cobol)
189171

0 commit comments

Comments
 (0)