Skip to content
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

Support ruff server #4451

Closed
rassie opened this issue May 8, 2024 · 5 comments
Closed

Support ruff server #4451

rassie opened this issue May 8, 2024 · 5 comments

Comments

@rassie
Copy link

rassie commented May 8, 2024

According to astral-sh/ruff#10158, ruff server is a re-implementation of ruff-lsp in Rust and just by that property it is very probable that ruff-lsp will be deprecated in near future. Would be nice to have a lsp-mode client for ruff server by that point.

@indigoviolet
Copy link
Contributor

This is now available in beta: https://github.com/astral-sh/ruff/tree/main/crates/ruff_server#setup

Here's the blogpost about it: https://astral.sh/blog/ruff-v0.4.5

@indigoviolet
Copy link
Contributor

indigoviolet commented Jun 4, 2024

A very basic version that seems to be working for me:

(with-eval-after-load 'lsp-mode
  (lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection '("ruff" "server" "--preview"))
     :major-modes '(python-mode)
     :priority 1
     :add-on? t
     :multi-root t
     :server-id 'ruff-server)
    )
  )
(setq! lsp-disabled-clients '(python-mode . (ruff-lsp)))

@PBorocz
Copy link

PBorocz commented Jul 28, 2024

FWIW (as a Emacs elisp neophyte), this worked for me:

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs '(python-ts-mode . ("~/.local/bin/ruff-lsp"))))

went to:

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs '(python-ts-mode . ("~/.local/bin/ruff" "server"))))

at the end of my use-package eglot definition (against a ruff installed using pipx)

@FrauH0lle
Copy link

I am not sure if eglot configuration will help lsp-mode users ...

What @indigoviolet wrote works, however even shorter is to modify lsp-ruff-lsp-server-command:

(with-eval-after-load 'lsp-mode
  (setq lsp-ruff-lsp-server-command '("ruff" "server")))

@jcs090218
Copy link
Member

The server is now supported. Added in #4543.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants