[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot a5b7b7d933 04/33: Fix #688: Support multiple serv
From: |
Stefan Kangas |
Subject: |
[elpa] externals/eglot a5b7b7d933 04/33: Fix #688: Support multiple servers out-of-box for same mode |
Date: |
Sat, 8 Jan 2022 12:30:48 -0500 (EST) |
branch: externals/eglot
commit a5b7b7d933b97db9ce5f8b7dcc8c866f7c35b220
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Fix #688: Support multiple servers out-of-box for same mode
Also per #537.
* eglot.el (eglot-alternatives): new helper.
(eglot-server-programs): Use it. Use clangd and pylsp.
* NEWS.md: Mention feature.
* README.md (Connecting to a server): Mention pylsp and clangd.
---
NEWS.md | 6 ++++++
README.md | 5 +++--
eglot.el | 28 +++++++++++++++++++++++++---
3 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index 03a22bcc53..ec39654929 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,10 @@
# (upcoming)
+##### Multiple servers supported out-of-box for same major mdoe
([#688][github#688])
+
+In practice, this removes the need for Eglot to "officially" bless one
+server over another. Thanks to Felicián Németh for the original idea.
+
##### TRAMP support ([#637][github#637], ([#463][github#463],
([#84][github#84])
Thanks to Brian Cully for the minimalist approach.
@@ -272,4 +277,5 @@ and now said bunch of references-->
[github#637]: https://github.com/joaotavora/eglot/issues/637
[github#643]: https://github.com/joaotavora/eglot/issues/643
[github#686]: https://github.com/joaotavora/eglot/issues/686
+[github#688]: https://github.com/joaotavora/eglot/issues/688
[github#695]: https://github.com/joaotavora/eglot/issues/695
diff --git a/README.md b/README.md
index e367b0fd97..ca78603474 100644
--- a/README.md
+++ b/README.md
@@ -39,12 +39,12 @@ find-library` can help you tell if that happened.
* Javascript's [TS & JS Language Server ][typescript-language-server]
* Rust's [rls][rls]
-* Python's [pyls][pyls]
+* Python's [pylsp][pylsp] or [pyls][pyls]
* Ruby's [solargraph][solargraph]
* Java's [Eclipse JDT Language Server][eclipse-jdt]
* Bash's [bash-language-server][bash-language-server]
* PHP's [php-language-server][php-language-server]
-* C/C++'s [ccls][ccls] ([cquery][cquery] and [clangd][clangd] also work)
+* C/C++'s [clangd][clangd] or [ccls][ccls]
* Haskell's [haskell-language-server][haskell-language-server]
* Elm's [elm-language-server][elm-language-server]
* Kotlin's [kotlin-language-server][kotlin-language-server]
@@ -540,6 +540,7 @@ Under the hood:
[lsp]: https://microsoft.github.io/language-server-protocol/
[rls]: https://github.com/rust-lang-nursery/rls
[pyls]: https://github.com/palantir/python-language-server
+[pylsp]: https://github.com/python-lsp/python-lsp-server
[gnuelpa]: https://elpa.gnu.org/packages/eglot.html
[melpa]: http://melpa.org/#/eglot
[typescript-language-server]:
https://github.com/theia-ide/typescript-language-server
diff --git a/eglot.el b/eglot.el
index 13d9952494..a739419e9d 100644
--- a/eglot.el
+++ b/eglot.el
@@ -95,15 +95,37 @@
:prefix "eglot-"
:group 'applications)
-(defvar eglot-server-programs '((rust-mode . (eglot-rls "rls"))
- (python-mode . ("pyls"))
+(defun eglot-alternatives (alternatives)
+ "Compute server-choosing function for `eglot-server-programs'.
+Each element of ALTERNATIVES is a string PROGRAM or a list of
+strings (PROGRAM ARGS...) where program names an LSP server
+program to start with ARGS. Returns a function of one
+argument."
+ (lambda (&optional interactive)
+ (let* ((listified (cl-loop for a in alternatives
+ collect (if (listp a) a (list a))))
+ (available (cl-remove-if-not #'executable-find listified :key
#'car)))
+ (cond ((and interactive (cdr available))
+ (let ((chosen (completing-read
+ "[eglot] More than one server executable
available:"
+ (mapcar #'car available)
+ nil t nil nil (car (car available)))))
+ (assoc chosen available #'equal)))
+ ((car available))
+ (t
+ (car listified))))))
+
+(defvar eglot-server-programs `((rust-mode . (eglot-rls "rls"))
+ (python-mode
+ . ,(eglot-alternatives '("pyls" "pylsp")))
((js-mode typescript-mode)
. ("typescript-language-server" "--stdio"))
(sh-mode . ("bash-language-server" "start"))
((php-mode phps-mode)
. ("php" "vendor/felixfbecker/\
language-server/bin/php-language-server.php"))
- ((c++-mode c-mode) . ("ccls"))
+ ((c++-mode c-mode) . ,(eglot-alternatives
+ '("clangd" "ccls")))
(((caml-mode :language-id "ocaml")
(tuareg-mode :language-id "ocaml")
reason-mode)
. ("ocamllsp"))
- [elpa] externals/eglot updated (1ac06d0bcc -> b197e092f9), Stefan Kangas, 2022/01/08
- [elpa] externals/eglot 1460324706 03/33: Update bug_report.md, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot 835aa0e9b3 06/33: Per #697, #645: Hard code an exception to "node_modules" directores, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot a5b7b7d933 04/33: Fix #688: Support multiple servers out-of-box for same mode,
Stefan Kangas <=
- [elpa] externals/eglot 194b178ef4 11/33: Close #712: Add support for LocationLink, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot 122dbb9d6e 14/33: Fix typo in user-visible eglot-ignored-server-capabilities, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot 9b63f21e75 15/33: Respect completion-regexp-alist in Eglot's completion table, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot c3f1b7b43f 25/33: Fix #779: Correct "GNU ELPA" typo, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot 670ee61169 23/33: Close #770: Mark eglot-completion-at-point capf "non-exclusive", Stefan Kangas, 2022/01/08
- [elpa] externals/eglot 5a717c3861 01/33: Fix #671: Allow staying out of flymake-mode, eldoc-mode, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot 44504db1ea 28/33: Use `locate-user-emacs-file` instead of `concat`, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot 5cc8df63d8 08/33: Fix #702: Consider TRAMP in eglot-alternatives, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot 0e6c0619da 09/33: Fix #703: Don't call eglot--executable-find more than needed, Stefan Kangas, 2022/01/08
- [elpa] externals/eglot c17bdf6c98 16/33: Fixup last commit, Stefan Kangas, 2022/01/08