From 29b44f7ec1dc6a094e751ec0af6fb950c7858a71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 20 Jun 2018 19:05:25 +0100 Subject: [PATCH] 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 --- lisp/progmodes/eglot.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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)) -- 2.39.2