|
40 | 40 | (require 'ht)
|
41 | 41 | (require 'imenu)
|
42 | 42 | (require 'inline)
|
| 43 | +(require 'jka-compr) |
43 | 44 | (require 'json)
|
44 | 45 | (require 'lv)
|
45 | 46 | (require 'markdown-mode)
|
@@ -7192,19 +7193,33 @@ nil."
|
7192 | 7193 |
|
7193 | 7194 |
|
7194 | 7195 | ;; Download URL handling
|
7195 |
| -(cl-defun lsp-download-install (callback error-callback &key url store-path &allow-other-keys) |
7196 |
| - (let ((url (lsp-resolve-value url)) |
7197 |
| - (store-path (lsp-resolve-value store-path))) |
| 7196 | +(cl-defun lsp-download-install (callback error-callback &key url store-path decompress &allow-other-keys) |
| 7197 | + (let* ((url (lsp-resolve-value url)) |
| 7198 | + (store-path (lsp-resolve-value store-path)) |
| 7199 | + ;; (decompress (lsp-resolve-value decompress)) |
| 7200 | + (download-path |
| 7201 | + (pcase decompress |
| 7202 | + (:gzip (concat store-path ".gz")) |
| 7203 | + (:zip (concat store-path ".zip")) |
| 7204 | + (`nil store-path) |
| 7205 | + (_ (error ":decompress must be `:gzip', `:zip' or `nil'"))))) |
7198 | 7206 | (make-thread
|
7199 | 7207 | (lambda ()
|
7200 | 7208 | (condition-case err
|
7201 | 7209 | (progn
|
7202 |
| - (when (f-exists? store-path) |
7203 |
| - (f-delete store-path)) |
7204 |
| - (lsp--info "Starting to download %s to %s..." url store-path) |
7205 |
| - (mkdir (f-parent store-path) t) |
7206 |
| - (url-copy-file url store-path) |
7207 |
| - (lsp--info "Finished downloading %s..." store-path) |
| 7210 | + (when (f-exists? download-path) |
| 7211 | + (f-delete download-path)) |
| 7212 | + (lsp--info "Starting to download %s to %s..." url download-path) |
| 7213 | + (mkdir (f-parent download-path) t) |
| 7214 | + (url-copy-file url download-path) |
| 7215 | + (lsp--info "Finished downloading %s..." download-path) |
| 7216 | + (when decompress |
| 7217 | + (lsp--info "Decompressing %s..." download-path) |
| 7218 | + (pcase decompress |
| 7219 | + (:gzip |
| 7220 | + (lsp-gunzip download-path)) |
| 7221 | + (:zip (lsp-unzip download-path store-path))) |
| 7222 | + (lsp--info "Decompressed %s..." store-path)) |
7208 | 7223 | (funcall callback))
|
7209 | 7224 | (error (funcall error-callback err)))))))
|
7210 | 7225 |
|
@@ -7243,7 +7258,24 @@ STORE-PATH to make it executable."
|
7243 | 7258 | (unless lsp-unzip-script
|
7244 | 7259 | (error "Unable to find `unzip' or `powershell' on the path, please customize `lsp-unzip-script'"))
|
7245 | 7260 | (shell-command (format lsp-unzip-script zip-file dest)))
|
| 7261 | + |
| 7262 | +;; gunzip |
| 7263 | + |
| 7264 | +(defconst lsp-ext-gunzip-script "gzip -d %1$s" |
| 7265 | + "Script to decompress a gzippped file with gzip.") |
| 7266 | + |
| 7267 | +(defcustom lsp-gunzip-script (cond ((executable-find "gzip") lsp-ext-gunzip-script) |
| 7268 | + (t nil)) |
| 7269 | + "The script to decompress a gzipped file. Should be a format string with one argument for the file to be decompressed in place." |
| 7270 | + :group 'lsp-mode |
| 7271 | + :type 'string |
| 7272 | + :package-version '(lsp-mode . "7.1")) |
7246 | 7273 |
|
| 7274 | +(defun lsp-gunzip (gz-file) |
| 7275 | + "Decompress file in place." |
| 7276 | + (unless lsp-gunzip-script |
| 7277 | + (error "Unable to find `gzip' on the path, please either customize `lsp-gunzip-script' or manually decompress %s" gz-file)) |
| 7278 | + (shell-command (format lsp-gunzip-script gz-file))) |
7247 | 7279 |
|
7248 | 7280 | ;; VSCode marketplace
|
7249 | 7281 |
|
|
0 commit comments