From: João Távora Date: Wed, 20 Jun 2018 18:05:25 +0000 (+0100) Subject: Guess server for js2-mode and rjsx-mode X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~497 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=29b44f7ec1dc6a094e751ec0af6fb950c7858a71;p=emacs.git Guess server for js2-mode and rjsx-mode * eglot.el (eglot-server-programs): Add entries for js2-mode and rjsx-mode. Coalesce entries for c++ and c-mode. Improve docstring. (eglot--guess-contact): Allow lists are keys in eglot-server-programs. GitHub-reference: close https://github.com/joaotavora/eglot/issues/26 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index ecbd509b003..447e8c17f25 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -78,15 +78,19 @@ (defvar eglot-server-programs '((rust-mode . (eglot-rls "rls")) (python-mode . ("pyls")) - (js-mode . ("javascript-typescript-stdio")) + ((js-mode + js2-mode + rjsx-mode) . ("javascript-typescript-stdio")) (sh-mode . ("bash-language-server" "start")) - (c++-mode . (eglot-cquery "cquery")) - (c-mode . (eglot-cquery "cquery")) + ((c++-mode + c-mode) . (eglot-cquery "cquery")) (php-mode . ("php" "vendor/felixfbecker/\ language-server/bin/php-language-server.php"))) "How the command `eglot' guesses the server to start. An association list of (MAJOR-MODE . SPEC) pair. MAJOR-MODE is a -mode symbol. SPEC is +mode symbol, or a list of mode symbols. The associated SPEC +specifies how to start a server for managing buffers of those +modes. SPEC can be: * In the most common case, a list of strings (PROGRAM [ARGS...]). PROGRAM is called with ARGS and is expected to serve LSP requests @@ -359,7 +363,10 @@ be guessed." (eglot--error "Can't guess mode to manage for `%s'" (current-buffer))) (t guessed-mode))) (project (or (project-current) `(transient . ,default-directory))) - (guess (cdr (assoc managed-mode eglot-server-programs))) + (guess (cdr (assoc managed-mode eglot-server-programs + (lambda (m1 m2) + (or (eq m1 m2) + (and (listp m1) (memq m2 m1))))))) (class (or (and (consp guess) (symbolp (car guess)) (prog1 (car guess) (setq guess (cdr guess)))) 'eglot-lsp-server))