From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Niall Dooley Newsgroups: gmane.emacs.bugs Subject: bug#67442: [PATCH] eglot: Add ruff-lsp as an alternative python server Date: Mon, 27 Nov 2023 11:22:02 +0100 Message-ID: References: <83fs0uccoj.fsf@gnu.org> <834jhac7hw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30306"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 67442@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 27 15:19:17 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r7cSC-0007gU-Oy for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Nov 2023 15:19:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7cRx-0003Kp-Pp; Mon, 27 Nov 2023 09:19:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7cRs-0003K7-90 for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 09:18:57 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r7cRr-0005hV-Vw for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 09:18:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r7cRy-0000ru-48 for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 09:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Niall Dooley Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Nov 2023 14:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67442 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67442-submit@debbugs.gnu.org id=B67442.17010946823273 (code B ref 67442); Mon, 27 Nov 2023 14:19:02 +0000 Original-Received: (at 67442) by debbugs.gnu.org; 27 Nov 2023 14:18:02 +0000 Original-Received: from localhost ([127.0.0.1]:43577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7cR0-0000qZ-4K for submit@debbugs.gnu.org; Mon, 27 Nov 2023 09:18:02 -0500 Original-Received: from mail-oo1-xc34.google.com ([2607:f8b0:4864:20::c34]:48513) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7YlO-00006U-7b for 67442@debbugs.gnu.org; Mon, 27 Nov 2023 05:22:51 -0500 Original-Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-58d54612d9cso940641eaf.1 for <67442@debbugs.gnu.org>; Mon, 27 Nov 2023 02:22:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701080558; x=1701685358; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=g37fp9uxHhsF8hd4t56GhocBGQtlgpbvHl28pCn9dQ0=; b=EmmQNF8WJJiRFSMGgJ6oebVgkLiYRDyyyxq8Vik2UYSm21o/Pf6H8ZxgtPtaeatBrS j1qsvWH3/93bQG0yp6thxJswGjw4qlEZuA/wmOtA+P8T0y0IIKMTZS9/fCoGLZe5a+jU s9HW/JybLdWYoiSybz4Auh31q/0IyfcjqpsQnVd1TiGAvqguakqkq752Fwh0R73bAwFc abZgCqEd7ABb+FzxmVpk2yJYaK8LKL6K4gjNdu3IkFv/5AouCuW7kVcV7fw+NNmxcGGs 7byf6JLD76/NcK8fV35AJsG0z40tyvBLLPx9a+kaiYZKMeyH8hA3dRNphlZJBVn9L9mL gKrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701080558; x=1701685358; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g37fp9uxHhsF8hd4t56GhocBGQtlgpbvHl28pCn9dQ0=; b=U5Cg/UB0QRzUSv+3eW7kvS5NKhukNkOUlBQiKYl/gnY4iremKF7GUPq83YrNXbr6Rr +YKSpugJnzH5d3RoniOXaCDegW6KEAUb5M8WLjkPgbIb94bfsDConT5DyzcBt8nWQlsF 9kuHmWfVRskJkw7I/IMOD/IIe8k8BjtklAjlFKIGrr+ZSQIkb8I/sBXnTmuLM3cp2zTH jHvASM3zijqWISrfZzqib1qbkjacv7cX2/VXOHQ8hGnG0iARKhwJPG++48jc/nH9CcAy 1LBwis1WXvwru1CMNTGy3kDm09KwjEAt3OSvYhVHJZH9w9qfDrPlwTmYR+bvSTWD5pWw eYOQ== X-Gm-Message-State: AOJu0Yzk/ZV5skhiDHNyxBMiYBzDMcEeb9ZOL06Z7UpEKi9m5lBZV3HP H41YeEDFhQ62baqQ5R0F/TahlpYQnhkaCpUw8cA= X-Google-Smtp-Source: AGHT+IF0B3iDhzz8cXKRlFoFsSQo9nTv2SxlrKENy7fZ1fe9U/r1TUcVs2aeOkXdjT9DWLME/bkYIeK84oUpAV45t4A= X-Received: by 2002:a05:6820:514:b0:58d:9d79:abc with SMTP id m20-20020a056820051400b0058d9d790abcmr592532ooj.1.1701080558299; Mon, 27 Nov 2023 02:22:38 -0800 (PST) In-Reply-To: X-Mailman-Approved-At: Mon, 27 Nov 2023 09:18:01 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275131 Archived-At: On Sun, 26 Nov 2023 at 10:53, Jo=C3=A3o T=C3=A1vora = 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=3Dstdin" "-") 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