diff options
author | David Morgan <djm_uk@protonmail.com> | 2024-12-13 12:22:55 +0000 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2024-12-13 12:22:55 +0000 |
commit | eb6014440cebce8ade1034f8d09ad98cdfe32ee0 (patch) | |
tree | 32af85d66b60bfaee54d239d3f088f19aa17e9de /.emacs.d | |
parent | 6ee84789896fc713f470dbd4979aa905d407d40c (diff) | |
download | dotfiles-eb6014440cebce8ade1034f8d09ad98cdfe32ee0.tar.gz |
Try emacs-lsp-booster
Diffstat (limited to '.emacs.d')
-rw-r--r-- | .emacs.d/lisp/init-lsp.el | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/.emacs.d/lisp/init-lsp.el b/.emacs.d/lisp/init-lsp.el index 49ff138..9a0b4d5 100644 --- a/.emacs.d/lisp/init-lsp.el +++ b/.emacs.d/lisp/init-lsp.el @@ -56,7 +56,38 @@ lsp-references-exclude-definition t ;; user cider for indendation and eldoc lsp-enable-indentation nil - lsp-eldoc-enable-hover nil)) + lsp-eldoc-enable-hover nil) + + ;; Copied from https://github.com/blahgeek/emacs-lsp-booster/blob/4200ed6ae0cd83b8e3fd1dbefb09121480951a22/README.md#configure-lsp-mode + (defun lsp-booster--advice-json-parse (old-fn &rest args) + "Try to parse bytecode instead of json." + (or + (when (equal (following-char) ?#) + (let ((bytecode (read (current-buffer)))) + (when (byte-code-function-p bytecode) + (funcall bytecode)))) + (apply old-fn args))) + (advice-add (if (progn (require 'json) + (fboundp 'json-parse-buffer)) + 'json-parse-buffer + 'json-read) + :around + #'lsp-booster--advice-json-parse) + (defun lsp-booster--advice-final-command (old-fn cmd &optional test?) + "Prepend emacs-lsp-booster command to lsp CMD." + (let ((orig-result (funcall old-fn cmd test?))) + (if (and (not test?) ;; for check lsp-server-present? + (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper + lsp-use-plists + (not (functionp 'json-rpc-connection)) ;; native json-rpc + (executable-find "emacs-lsp-booster")) + (progn + (when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH) + (setcar orig-result command-from-exec-path)) + (message "Using emacs-lsp-booster for %s!" orig-result) + (cons "emacs-lsp-booster" orig-result)) + orig-result))) + (advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command)) (provide 'init-lsp) ;;; init-lsp.el ends here |