Function: eglot--lookup-mode
eglot--lookup-mode is a byte-compiled function defined in eglot.el.gz.
Signature
(eglot--lookup-mode MODE)
Documentation
Lookup eglot-server-programs for MODE.
Return (LANGUAGES . CONTACT-PROXY).
MANAGED-MODES is a list with MODE as its first element. Subsequent elements are other major modes also potentially managed by the server that is to manage MODE.
LANGUAGE-IDS is a list of the same length as MANAGED-MODES. Each
elem is derived from the corresponding mode name, if not
specified in eglot-server-programs (which see).
CONTACT-PROXY is the value of the corresponding
eglot-server-programs entry.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(defun eglot--lookup-mode (mode)
"Lookup `eglot-server-programs' for MODE.
Return (LANGUAGES . CONTACT-PROXY).
MANAGED-MODES is a list with MODE as its first element.
Subsequent elements are other major modes also potentially
managed by the server that is to manage MODE.
LANGUAGE-IDS is a list of the same length as MANAGED-MODES. Each
elem is derived from the corresponding mode name, if not
specified in `eglot-server-programs' (which see).
CONTACT-PROXY is the value of the corresponding
`eglot-server-programs' entry."
(cl-flet ((languages (main-mode-sym specs)
(let* ((res
(mapcar (jsonrpc-lambda (sym &key language-id &allow-other-keys)
(cons sym
(or language-id
(or (get sym 'eglot-language-id)
(replace-regexp-in-string
"\\(?:-ts\\)?-mode$" ""
(symbol-name sym))))))
specs))
(head (cl-find main-mode-sym res :key #'car)))
(cons head (delq head res)))))
(cl-loop
for (modes . contact) in eglot-server-programs
for specs = (mapcar #'eglot--ensure-list
(if (or (symbolp modes) (keywordp (cadr modes)))
(list modes) modes))
thereis (cl-some (lambda (spec)
(cl-destructuring-bind (sym &key &allow-other-keys) spec
(and (provided-mode-derived-p mode sym)
(cons (languages sym specs) contact))))
specs))))