all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server
@ 2023-11-24 22:42 Niall Dooley
  2023-11-25  9:19 ` Eli Zaretskii
  2023-11-25 11:09 ` Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: Niall Dooley @ 2023-11-24 22:42 UTC (permalink / raw)
  To: 67442

[-- Attachment #1: Type: text/plain, Size: 1416 bytes --]

ruff-lsp [1] is a Language Server Protocol implementation for Ruff [2,
3], an extremely fast Python linter and code formatter, written in
Rust.

It supports surfacing Ruff diagnostics and providing Code Actions to
fix them, but is intended to be used alongside another Python LSP in
order to support features like navigation and autocompletion.

[1]: https://github.com/astral-sh/ruff-lsp
[2]: https://github.com/astral-sh/ruff
[3]: https://docs.astral.sh/ruff/
---
 lisp/progmodes/eglot.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 48ea33c3ee1..d7d91bddb01 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -216,7 +216,7 @@ eglot-server-programs
                                 (vimrc-mode . ("vim-language-server"
"--stdio"))
                                 ((python-mode python-ts-mode)
                                  . ,(eglot-alternatives
-                                     '("pylsp" "pyls"
("pyright-langserver" "--stdio") "jedi-language-server")))
+                                     '("pylsp" "pyls"
("pyright-langserver" "--stdio") "jedi-language-server" "ruff-lsp")))
                                 ((js-json-mode json-mode json-ts-mode)
                                  . ,(eglot-alternatives
'(("vscode-json-language-server" "--stdio")

("vscode-json-languageserver" "--stdio")
-- 
2.30.2

[-- Attachment #2: 0001-eglot-Add-ruff-lsp-as-an-alternative-python-server.patch --]
[-- Type: text/x-patch, Size: 1693 bytes --]

From b1cfc2d980adb3f9963ab2c8607f4fa78e356a2d Mon Sep 17 00:00:00 2001
From: Niall Dooley <dooleyn@gmail.com>
Date: Fri, 24 Nov 2023 16:21:39 +0100
Subject: [PATCH] eglot: Add ruff-lsp as an alternative python server

ruff-lsp [1] is a Language Server Protocol implementation for Ruff [2,
3], an extremely fast Python linter and code formatter, written in
Rust.

It supports surfacing Ruff diagnostics and providing Code Actions to
fix them, but is intended to be used alongside another Python LSP in
order to support features like navigation and autocompletion.

[1]: https://github.com/astral-sh/ruff-lsp
[2]: https://github.com/astral-sh/ruff
[3]: https://docs.astral.sh/ruff/
---
 lisp/progmodes/eglot.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 48ea33c3ee1..d7d91bddb01 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -216,7 +216,7 @@ eglot-server-programs
                                 (vimrc-mode . ("vim-language-server" "--stdio"))
                                 ((python-mode python-ts-mode)
                                  . ,(eglot-alternatives
-                                     '("pylsp" "pyls" ("pyright-langserver" "--stdio") "jedi-language-server")))
+                                     '("pylsp" "pyls" ("pyright-langserver" "--stdio") "jedi-language-server" "ruff-lsp")))
                                 ((js-json-mode json-mode json-ts-mode)
                                  . ,(eglot-alternatives '(("vscode-json-language-server" "--stdio")
                                                           ("vscode-json-languageserver" "--stdio")
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server
  2023-11-24 22:42 bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server Niall Dooley
@ 2023-11-25  9:19 ` Eli Zaretskii
  2023-11-25 11:09 ` Eli Zaretskii
  1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2023-11-25  9:19 UTC (permalink / raw)
  To: Niall Dooley; +Cc: 67442

merge 67442 67441
thanks

> From: Niall Dooley <dooleyn@gmail.com>
> Date: Fri, 24 Nov 2023 23:42:28 +0100
> 
> ruff-lsp [1] is a Language Server Protocol implementation for Ruff [2,
> 3], an extremely fast Python linter and code formatter, written in
> Rust.
> 
> It supports surfacing Ruff diagnostics and providing Code Actions to
> fix them, but is intended to be used alongside another Python LSP in
> order to support features like navigation and autocompletion.
> 
> [1]: https://github.com/astral-sh/ruff-lsp
> [2]: https://github.com/astral-sh/ruff
> [3]: https://docs.astral.sh/ruff/

Thanks, AFAICT this is an exact duplicate of bug#67441.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server
  2023-11-24 22:42 bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server Niall Dooley
  2023-11-25  9:19 ` Eli Zaretskii
@ 2023-11-25 11:09 ` Eli Zaretskii
  2023-11-25 11:19   ` Niall Dooley
  2023-11-25 12:39   ` João Távora
  1 sibling, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2023-11-25 11:09 UTC (permalink / raw)
  To: Niall Dooley, João Távora; +Cc: 67442

> From: Niall Dooley <dooleyn@gmail.com>
> Date: Fri, 24 Nov 2023 23:42:28 +0100
> 
> ruff-lsp [1] is a Language Server Protocol implementation for Ruff [2,
> 3], an extremely fast Python linter and code formatter, written in
> Rust.
> 
> It supports surfacing Ruff diagnostics and providing Code Actions to
> fix them, but is intended to be used alongside another Python LSP in
> order to support features like navigation and autocompletion.

What do you mean by "alongside"?

João, does Eglot support such "alongside" servers?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server
  2023-11-25 11:09 ` Eli Zaretskii
@ 2023-11-25 11:19   ` Niall Dooley
  2023-11-25 12:39   ` João Távora
  1 sibling, 0 replies; 8+ messages in thread
From: Niall Dooley @ 2023-11-25 11:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 67442, João Távora

On Sat, 25 Nov 2023 at 12:09, Eli Zaretskii <eliz@gnu.org> wrote:
> What do you mean by "alongside"?

That excerpt is taken directly from the ruff-lsp README.  It is not a
fully fledged LSP server like pylsp and does not provided features such
as candidates for autocompletion that users may expect from an LSP
server.  To also have such features it must be used with another server.
To my knowledge Eglot does not (yet) support the use of multiple
servers.

In short it is a linter + formatter made available through the LSP
protocol.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server
  2023-11-25 11:09 ` Eli Zaretskii
  2023-11-25 11:19   ` Niall Dooley
@ 2023-11-25 12:39   ` João Távora
  2023-11-25 13:00     ` Eli Zaretskii
  1 sibling, 1 reply; 8+ messages in thread
From: João Távora @ 2023-11-25 12:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Niall Dooley, 67442

[-- Attachment #1: Type: text/plain, Size: 739 bytes --]

On Sat, Nov 25, 2023, 11:09 Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Niall Dooley <dooleyn@gmail.com>
> > Date: Fri, 24 Nov 2023 23:42:28 +0100
> >
> > ruff-lsp [1] is a Language Server Protocol implementation for Ruff [2,
> > 3], an extremely fast Python linter and code formatter, written in
> > Rust.
> >
> > It supports surfacing Ruff diagnostics and providing Code Actions to
> > fix them, but is intended to be used alongside another Python LSP in
> > order to support features like navigation and autocompletion.
>
> What do you mean by "alongside"?
>
> João, does Eglot support such "alongside" servers?
>

No. This is a feature on my to-do list, but alas I haven't had time to work
on it.

João

>

[-- Attachment #2: Type: text/html, Size: 1413 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server
  2023-11-25 12:39   ` João Távora
@ 2023-11-25 13:00     ` Eli Zaretskii
  2023-11-26  9:53       ` João Távora
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2023-11-25 13:00 UTC (permalink / raw)
  To: João Távora; +Cc: dooleyn, 67442

> From: João Távora <joaotavora@gmail.com>
> Date: Sat, 25 Nov 2023 12:39:22 +0000
> Cc: Niall Dooley <dooleyn@gmail.com>, 67442@debbugs.gnu.org
> 
> On Sat, Nov 25, 2023, 11:09 Eli Zaretskii <eliz@gnu.org> wrote:
> 
>  > It supports surfacing Ruff diagnostics and providing Code Actions to
>  > fix them, but is intended to be used alongside another Python LSP in
>  > order to support features like navigation and autocompletion.
> 
>  What do you mean by "alongside"?
> 
>  João, does Eglot support such "alongside" servers?
> 
> No. This is a feature on my to-do list, but alas I haven't had time to work on it.

OK, thanks.  So AFAIU, we cannot install this change yet, right?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server
  2023-11-25 13:00     ` Eli Zaretskii
@ 2023-11-26  9:53       ` João Távora
  2023-11-27 10:22         ` Niall Dooley
  0 siblings, 1 reply; 8+ messages in thread
From: João Távora @ 2023-11-26  9:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: dooleyn, 67442

[-- Attachment #1: Type: text/plain, Size: 1907 bytes --]

On Sat, Nov 25, 2023, 13:01 Eli Zaretskii <eliz@gnu.org> wrote:

> > From: João Távora <joaotavora@gmail.com>
> > Date: Sat, 25 Nov 2023 12:39:22 +0000
> > Cc: Niall Dooley <dooleyn@gmail.com>, 67442@debbugs.gnu.org
> >
> > On Sat, Nov 25, 2023, 11:09 Eli Zaretskii <eliz@gnu.org> wrote:
> >
> >  > It supports surfacing Ruff diagnostics and providing Code Actions to
> >  > fix them, but is intended to be used alongside another Python LSP in
> >  > order to support features like navigation and autocompletion.
> >
> >  What do you mean by "alongside"?
> >
> >  João, does Eglot support such "alongside" servers?
> >
> > No. This is a feature on my to-do list, but alas I haven't had time to
> work on it.
>
> OK, thanks.  So AFAIU, we cannot install this change yet, right?
>

We can. If you read this patch it establishes ruff as an "alternative"
('eglot-alternative'), not as an "alongside" companion.

But just because we can doesn't mean we should. It's possible that the ruff
server wasn't meant to be a full alternative to those other servers.
Reading from its website hints ruff is mainly a linter, so it has a
fraction of what other servers have

The proponents of this patch should argue in terms of ruff-only LSP support
in python buffers. Maybe enough value that it's reasonable to install
as-is, maybe not and we should wait for 'eglot-alongside'.

Or just wait for someone to code a flymake-ruff backend in python-mode.el.
That seems much more promising way to get the intended ruff experience into
Emacs.

There is also the common misconception (not sure if the case here) that if
a server isn't mentioned in 'eglot-server-programs' directly then Eglot
doesn't support it. And this is far from the truth: if 'ruff' is installed
in a user's machine M-x eglot can easily be made to prompt for it. I've
tried dozens of servers like that.

João

[-- Attachment #2: Type: text/html, Size: 3154 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server
  2023-11-26  9:53       ` João Távora
@ 2023-11-27 10:22         ` Niall Dooley
  0 siblings, 0 replies; 8+ messages in thread
From: Niall Dooley @ 2023-11-27 10:22 UTC (permalink / raw)
  To: João Távora; +Cc: Eli Zaretskii, 67442

On Sun, 26 Nov 2023 at 10:53, João Távora <joaotavora@gmail.com> wrote:
> But just because we can doesn't mean we should. It's possible that the
  ruff server wasn't meant to be a full alternative to those other
  servers. Reading from its website hints ruff is mainly a linter, so it
  has a fraction of what other servers have

It is also a formatter but yes it does not provide all the features one
might expect from an LSP server.  Do the others?  I don't know if it
will provide other features in the future.  I presume if more features
are added to ruff then they would also be added to ruff-lsp.

> The proponents of this patch should argue in terms of ruff-only LSP
  support in python buffers. Maybe enough value that it's reasonable to
  install as-is, maybe not and we should wait for 'eglot-alongside'.

My argument for its inclusion is that it is a server adhering to the LSP
protocol and thus can be listed as an alternative.  Its inclusion offers
users the choice to use it or not.  It would mean users would not have
to write, install or configure built-in or third party packages to use
ruff to lint, format or organize imports in their python projects.  They
would simply need to open a python file and M-x eglot to have ruff
perform these functions.  I think users aware of it will be aware of its
capabilities and limitations.  Ruff is a young project but quickly
replacing the other linters/formatters in the python ecosystem within a
single tool.

Counter argument a ruff plugin exists for pylsp which is already listed
as an alternative and offers other LSP features not provided by
ruff-lsp.

> Or just wait for someone to code a flymake-ruff backend in
  python-mode.el. That seems much more promising way to get the intended
  ruff experience into Emacs.

That already exists [1] but I've been able to have ruff lint my code by
simply setting `python-flymake-command' as follows:

("ruff" "check" "--quiet" "--stdin-filename=stdin" "-")

This doesn't include a "ruff" prefix identifying the source of the
flymake report like we get when using it via eglot but I believe that is
because servers provides a :source parameter to distinguish multiple
sources.  Could such a prefix be added to flymake reports when not used
via eglot?  I think it would be an improvement even if they could only
be one source of the report.

Neither of these solutions allow the user to make use of the formatting
capabilities or other code actions of ruff-lsp.  Another package would
have to be used to make use of these capabilities.

> There is also the common misconception (not sure if the case here)
  that if a server isn't mentioned in 'eglot-server-programs' directly
  then Eglot doesn't support it. And this is far from the truth: if
  'ruff' is installed in a user's machine M-x eglot can easily be made
  to prompt for it. I've tried dozens of servers like that.

Not here but I can see why that might be the case - users may assume
those listed in Eglot's README are only those that are supported.  Small
correction it is 'ruff-lsp' that would need to be installed which
naturally includes 'ruff' as a dependency.

[1] https://github.com/erickgnavar/flymake-ruff





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-11-27 10:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-24 22:42 bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server Niall Dooley
2023-11-25  9:19 ` Eli Zaretskii
2023-11-25 11:09 ` Eli Zaretskii
2023-11-25 11:19   ` Niall Dooley
2023-11-25 12:39   ` João Távora
2023-11-25 13:00     ` Eli Zaretskii
2023-11-26  9:53       ` João Távora
2023-11-27 10:22         ` Niall Dooley

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.