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