Skip to content

Commit

Permalink
Update ruff-lsp to ruff of Python (emacs-lsp#4543)
Browse files Browse the repository at this point in the history
* update ruff-lsp to ruff

* rename lsp-ruff-lsp to ruff-lsp

* change custom var and some crumbs of ruff-lsp to ruff

* change log

* tiny change
  • Loading branch information
ccqpein authored Sep 14, 2024
1 parent 213f207 commit 6447c32
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 46 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Add basic support for [[https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics][pull diagnostics]] requests.
* Add ~lsp-flush-delayed-changes-before-next-message~ customization point to enforce throttling document change notifications.
* Fix bug in ~rust-analyzer.check.features~ configuration via ~lsp-rust-checkonsave-features~ Emacs setting: we were defaulting to ~[]~, but ~rust-analyzer~ defaults to inheriting the value from ~rust-analyzer.cargo.features~. The bug resulted in code hidden behind features not getting type checked when those features were enabled by setting ~rust-analyzer.cargo.features~ via the ~lsp-rust-features~ Emacs setting.
* Change ~ruff-lsp~ to ~ruff~ for python lsp client. All ~ruff-lsp~ customizable variable change to ~ruff~. Lsp server command now is ~["ruff" "server"]~ instead of ~["ruff-lsp"]~.

** 9.0.0
* Add language server config for QML (Qt Modeling Language) using qmlls.
Expand Down
81 changes: 41 additions & 40 deletions clients/lsp-ruff-lsp.el → clients/lsp-ruff.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; lsp-ruff-lsp.el --- ruff-lsp support -*- lexical-binding: t; -*-
;;; lsp-ruff.el --- ruff lsp support -*- lexical-binding: t; -*-

;; Copyright (C) 2023 Freja Nordsiek
;;
Expand All @@ -20,96 +20,97 @@

;;; Commentary:

;; ruff-lsp Client for the Python programming language
;; ruff LSP Client for the Python programming language

;;; Code:

(require 'lsp-mode)

(defgroup lsp-ruff-lsp nil
"LSP support for Python, using ruff-lsp's Python Language Server."
(defgroup lsp-ruff nil
"LSP support for Python, using ruff's Python Language Server."
:group 'lsp-mode
:link '(url-link "https://github.com/charliermarsh/ruff-lsp"))
:link '(url-link "https://github.com/astral-sh/ruff"))

(defcustom lsp-ruff-lsp-server-command '("ruff-lsp")
"Command to start ruff-lsp."
(defcustom lsp-ruff-server-command '("ruff" "server")
"Command to start ruff lsp.
Previous ruff-lsp should change this to (\"ruff-lsp\")"
:risky t
:type '(repeat string)
:group 'lsp-ruff-lsp)
:group 'lsp-ruff)

(defcustom lsp-ruff-lsp-ruff-path ["ruff"]
(defcustom lsp-ruff-ruff-path ["ruff"]
"Paths to ruff to try, in order."
:risky t
:type 'lsp-string-vector
:group 'lsp-ruff-lsp)
:group 'lsp-ruff)

(defcustom lsp-ruff-lsp-ruff-args []
(defcustom lsp-ruff-ruff-args []
"Arguments, passed to ruff."
:risky t
:type 'lsp-string-vector
:group 'lsp-ruff-lsp)
:group 'lsp-ruff)

(defcustom lsp-ruff-lsp-log-level "error"
(defcustom lsp-ruff-log-level "error"
"Tracing level."
:type '(choice (const "debug")
(const "error")
(const "info")
(const "off")
(const "warn"))
:group 'lsp-ruff-lsp)
:group 'lsp-ruff)

(defcustom lsp-ruff-lsp-python-path "python3"
(defcustom lsp-ruff-python-path "python3"
"Path to the Python interpreter."
:risky t
:type 'string
:group 'lsp-ruff-lsp)
:group 'lsp-ruff)

(defcustom lsp-ruff-lsp-show-notifications "off"
(defcustom lsp-ruff-show-notifications "off"
"When notifications are shown."
:type '(choice (const "off")
(const "onError")
(const "onWarning")
(const "always"))
:group 'lsp-ruff-lsp)
:group 'lsp-ruff)

(defcustom lsp-ruff-lsp-advertize-organize-imports t
(defcustom lsp-ruff-advertize-organize-imports t
"Whether to report ability to handle source.organizeImports actions."
:type 'boolean
:group 'lsp-ruff-lsp)
:group 'lsp-ruff)

(defcustom lsp-ruff-lsp-advertize-fix-all t
(defcustom lsp-ruff-advertize-fix-all t
"Whether to report ability to handle source.fixAll actions."
:type 'boolean
:group 'lsp-ruff-lsp)
:group 'lsp-ruff)

(defcustom lsp-ruff-lsp-import-strategy "fromEnvironment"
"Where ruff is imported from if lsp-ruff-lsp-ruff-path is not set."
(defcustom lsp-ruff-import-strategy "fromEnvironment"
"Where ruff is imported from if lsp-ruff-ruff-path is not set."
:type '(choice (const "fromEnvironment")
(const "useBundled"))
:group 'lsp-ruff-lsp)
:group 'lsp-ruff)


(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection
(lambda () lsp-ruff-lsp-server-command))
(lambda () lsp-ruff-server-command))
:activation-fn (lsp-activate-on "python")
:server-id 'ruff-lsp
:server-id 'ruff
:priority -2
:add-on? t
:initialization-options
(lambda ()
(list :settings
(list :args lsp-ruff-lsp-ruff-args
:logLevel lsp-ruff-lsp-log-level
:path lsp-ruff-lsp-ruff-path
:interpreter (vector lsp-ruff-lsp-python-path)
:showNotifications lsp-ruff-lsp-show-notifications
:organizeImports (lsp-json-bool lsp-ruff-lsp-advertize-organize-imports)
:fixAll (lsp-json-bool lsp-ruff-lsp-advertize-fix-all)
:importStrategy lsp-ruff-lsp-import-strategy)))))

(lsp-consistency-check lsp-ruff-lsp)

(provide 'lsp-ruff-lsp)
;;; lsp-ruff-lsp.el ends here
(list :args lsp-ruff-ruff-args
:logLevel lsp-ruff-log-level
:path lsp-ruff-ruff-path
:interpreter (vector lsp-ruff-python-path)
:showNotifications lsp-ruff-show-notifications
:organizeImports (lsp-json-bool lsp-ruff-advertize-organize-imports)
:fixAll (lsp-json-bool lsp-ruff-advertize-fix-all)
:importStrategy lsp-ruff-import-strategy)))))

(lsp-consistency-check lsp-ruff)

(provide 'lsp-ruff)
;;; lsp-ruff.el ends here
8 changes: 4 additions & 4 deletions docs/lsp-clients.json
Original file line number Diff line number Diff line change
Expand Up @@ -941,11 +941,11 @@
"debugger": "Not available"
},
{
"name": "ruff-lsp",
"name": "ruff",
"full-name": "Python",
"server-name": "ruff-lsp",
"server-url": "https://github.com/charliermarsh/ruff-lsp",
"installation": "pip install ruff-lsp",
"server-name": "ruff",
"server-url": "https://github.com/astral-sh/ruff",
"installation": "pip install ruff (previous pip install ruff-lsp)",
"debugger": "Not available"
},
{
Expand Down
2 changes: 1 addition & 1 deletion lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ As defined by the Language Server Protocol 3.16."
lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator lsp-php lsp-pls
lsp-purescript lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms
lsp-qml lsp-r lsp-racket lsp-remark lsp-rf lsp-roslyn lsp-rubocop lsp-ruby-lsp
lsp-ruby-syntax-tree lsp-ruff-lsp lsp-rust lsp-semgrep lsp-shader
lsp-ruby-syntax-tree lsp-ruff lsp-rust lsp-semgrep lsp-shader
lsp-solargraph lsp-solidity lsp-sonarlint lsp-sorbet lsp-sourcekit
lsp-sql lsp-sqls lsp-steep lsp-svelte lsp-tailwindcss lsp-terraform
lsp-tex lsp-tilt lsp-toml lsp-trunk lsp-ttcn3 lsp-typeprof lsp-v
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ nav:
- Python (Palantir deprecated): page/lsp-pyls.md
- Python (Pyright): https://emacs-lsp.github.io/lsp-pyright
- Python (Microsoft): https://emacs-lsp.github.io/lsp-python-ms
- Python (Ruff): page/lsp-ruff-lsp.md
- Python (Ruff): page/lsp-ruff.md
- QML: page/lsp-qml.md
- R: page/lsp-r.md
- Racket (jeapostrophe): page/lsp-racket-langserver.md
Expand Down

0 comments on commit 6447c32

Please sign in to comment.