feat(lsp): set-eglot-client!: support fallback alternatives

This commit is contained in:
Henrik Lissner
2025-09-14 11:51:07 -04:00
parent 18eb710c34
commit da5d22ad35

View File

@@ -2,12 +2,17 @@
;;;###if (modulep! +eglot) ;;;###if (modulep! +eglot)
;;;###autodef ;;;###autodef
(defun set-eglot-client! (mode server-call) (defun set-eglot-client! (mode &rest alternatives)
"Add SERVER-CALL list as a possible lsp server for given major MODE. "Set ALTERNATIVES as the given eglot lsp server for given major MODE.
Example : (set-eglot-client! 'python-mode `(,(concat doom-data-dir \"lsp/mspyls/Microsoft.Python.LanguageServer\")))" MODE and ALTERNATIVES take after MAJOR-MODE and CONTACT in
`eglot-server-programs'. MODE can be one major mode symbol or a list thereof.
ALTERNATIVES specifies how to connect to a server in those modes."
(after! eglot (after! eglot
(add-to-list 'eglot-server-programs `(,mode . ,server-call)))) (add-to-list 'eglot-server-programs
(cons mode (if (cdr alternatives)
(eglot-alternatives alternatives)
alternatives)))))
;; HACK Eglot removed `eglot-help-at-point' in joaotavora/eglot@a044dec for a ;; HACK Eglot removed `eglot-help-at-point' in joaotavora/eglot@a044dec for a
;; more problematic approach of deferred to eldoc. Here, I've restored it. ;; more problematic approach of deferred to eldoc. Here, I've restored it.