-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert usage of pyls to pylsp. #688
Conversation
@douglasdavis , an excellent idea. I once tried to contribute to While I also much sympathize with the idea of cleaning up the trailing white space, I'd rather we make that a separate commit. So do you think you could appease this poor maintainer's OCD and provide this without the unsolicited whitespace changes in README.md, or put them in a separate PR? I'll then reword the commit message according to GNU Changelog style. |
João Távora ***@***.***> writes:
While I also much sympathize with the idea of cleaning up the trailing
white space, I'd rather we make that a separate commit. So do you
think you could appease this poor maintainer's OCD and provide this
without the unsolicited whitespace changes in README.md, or put them
in a separate PR? I'll then reword the commit message according to GNU
Changelog style.
Happy to! I think I took care of all of my overzealous before-save-hook
whitespace-cleanup changes. Also thanks for adjusting the commit message
|
I know the structure of `eglot-server-programs' is already quite complicated, but I wonder whether it would be worth the complexity to support both pyls and the new pylsp. For example, if the executable of pylsp is in the path, then eglot should select pylsp, otherwise it should continue with pyls. |
🙀 |
I must admit I'm not exactly sure if that's a yes or no! I'm happy to implement something like this (taking inspiration from (defun eglot--find-default-py-server (interactive)
(cond ((executable-find "pylsp") '("pylsp"))
((executable-find "pyls") '("pyls"))
(t '("pylsp")))) with the entry in OTOH, I think it would help guide users to transitioning to |
@douglasdavis sorry, it was a "no, not yet" to @nemethf, some sillyness that wasn't clear to anybody but me probably. But the idea is: let's not overcomplicate We can think about that fallback behaviour later on in a new issue. |
And yes @douglasdavis , your idea is probably the best way to go about implementing @nemethf 's idea. It's a little more verbose but it gets the presumably not-so-common job done. |
My only concern right now is that I don't know if this kind of patch counts as a "trivial", non-copyright-paperwork-requiring change. I think it does, but I'm not sure. Maybe @monnier or someone else can help? |
I actually have copyright assignment paperwork filed for GNU Emacs |
Douglas Raymond Davis? yup I see it. Great. |
My only concern right now is that I don't know if this kind of patch counts
as a "trivial", non-copyright-paperwork-requiring change. I think it does,
but I'm not sure.
I think it does, but it's irrelevant since he signed the paperwork
anyway ;-)
|
@douglasdavis , I was just playing with some code in #537 and @nemethf 's idea and I figured maybe we can keep supporting diff --git a/eglot.el b/eglot.el
index db468d8..0da5275 100644
--- a/eglot.el
+++ b/eglot.el
@@ -95,8 +95,28 @@
:prefix "eglot-"
:group 'applications)
-(defvar eglot-server-programs '((rust-mode . (eglot-rls "rls"))
- (python-mode . ("pyls"))
+(defun eglot-alternatives (alternatives)
+ "Compute server-picking function suitable 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."
+ (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")) |
+(defun eglot-alternatives (alternatives)
[...]
+ (let ((chosen (completing-read
+ "[eglot] More than one server executable available:"
[...]
+(defvar eglot-server-programs `((rust-mode . (eglot-rls "rls"))
+ (python-mode
+ . ,(eglot-alternatives '("pyls" "pylsp")))
The act of loading a file should not affect Emacs behavior, so the above
is problematic: just loading `eglot.el` will prompt the user regardless
if the user intends to use Eglot and even if the user has no intention
to edit Python code.
|
That's inside a lambda, Stefan, are you sure you're reading this right? |
That's inside a lambda, Stefan, are you sure you're reading this right?
<blush>Well, of course, I saw that.
I was just ...hmm... testing you!</blush>
|
😆 |
Hi @joaotavora, M-x eglot indeed finds |
In that case, if you don't mind, I'd rather apply that, while also mentioning |
…e mode Also per joaotavora/eglot#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.
…e mode Also per joaotavora/eglot#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.
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. #688: joaotavora/eglot#688 #537: joaotavora/eglot#537
Also per joaotavora/eglot#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. GitHub-reference: fix joaotavora/eglot#688
Palantir's python-language-server has been forked and a new maintained project has started at python-lsp-server (relevant issue: python-lsp/python-lsp-server#4, the contributors from the open source Python community were no longer able to commit to the Palantir project, leaving it unmaintained). This PR transitions
pyls
usage topylsp
. (I have copyright assignment paperwork done for GNU Emacs)