refactor(lsp): eglot-booster: conform to conventions

Ref: #8463
Amend: 1ede94c88a
This commit is contained in:
Henrik Lissner
2025-08-21 15:39:53 +02:00
parent 52e867d386
commit c2da4f20f2
2 changed files with 15 additions and 12 deletions

View File

@@ -164,20 +164,21 @@ server getting expensively restarted when reverting buffers."
(add-hook 'lsp-mode-hook #'lsp-completion-mode))
(when (modulep! +booster)
(defun lsp-booster--advice-final-command (old-fn cmd &optional test?)
(defadvice! +lsp--booster-final-command-a (fn cmd &optional test?)
"Prepend emacs-lsp-booster command to lsp CMD."
(let ((orig-result (funcall old-fn cmd test?)))
:around #'lsp-resolve-final-command
(let ((orig-result (funcall 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
(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)
(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)
(append '("emacs-lsp-booster" "--disable-bytecode" "--") orig-result))
orig-result)))
(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command)))
orig-result)))))
(use-package! lsp-ui
:hook (lsp-mode . lsp-ui-mode)