|
1 |
| -;;; lsp-ruff-lsp.el --- ruff-lsp support -*- lexical-binding: t; -*- |
| 1 | +;;; lsp-ruff.el --- ruff lsp support -*- lexical-binding: t; -*- |
2 | 2 |
|
3 | 3 | ;; Copyright (C) 2023 Freja Nordsiek
|
4 | 4 | ;;
|
|
20 | 20 |
|
21 | 21 | ;;; Commentary:
|
22 | 22 |
|
23 |
| -;; ruff-lsp Client for the Python programming language |
| 23 | +;; ruff LSP Client for the Python programming language |
24 | 24 |
|
25 | 25 | ;;; Code:
|
26 | 26 |
|
27 | 27 | (require 'lsp-mode)
|
28 | 28 |
|
29 |
| -(defgroup lsp-ruff-lsp nil |
30 |
| - "LSP support for Python, using ruff-lsp's Python Language Server." |
| 29 | +(defgroup lsp-ruff nil |
| 30 | + "LSP support for Python, using ruff's Python Language Server." |
31 | 31 | :group 'lsp-mode
|
32 |
| - :link '(url-link "https://github.com/charliermarsh/ruff-lsp")) |
| 32 | + :link '(url-link "https://github.com/astral-sh/ruff")) |
33 | 33 |
|
34 |
| -(defcustom lsp-ruff-lsp-server-command '("ruff-lsp") |
35 |
| - "Command to start ruff-lsp." |
| 34 | +(defcustom lsp-ruff-server-command '("ruff" "server") |
| 35 | + "Command to start ruff lsp. |
| 36 | +Previous ruff-lsp should change this to (\"ruff-lsp\")" |
36 | 37 | :risky t
|
37 | 38 | :type '(repeat string)
|
38 |
| - :group 'lsp-ruff-lsp) |
| 39 | + :group 'lsp-ruff) |
39 | 40 |
|
40 |
| -(defcustom lsp-ruff-lsp-ruff-path ["ruff"] |
| 41 | +(defcustom lsp-ruff-ruff-path ["ruff"] |
41 | 42 | "Paths to ruff to try, in order."
|
42 | 43 | :risky t
|
43 | 44 | :type 'lsp-string-vector
|
44 |
| - :group 'lsp-ruff-lsp) |
| 45 | + :group 'lsp-ruff) |
45 | 46 |
|
46 |
| -(defcustom lsp-ruff-lsp-ruff-args [] |
| 47 | +(defcustom lsp-ruff-ruff-args [] |
47 | 48 | "Arguments, passed to ruff."
|
48 | 49 | :risky t
|
49 | 50 | :type 'lsp-string-vector
|
50 |
| - :group 'lsp-ruff-lsp) |
| 51 | + :group 'lsp-ruff) |
51 | 52 |
|
52 |
| -(defcustom lsp-ruff-lsp-log-level "error" |
| 53 | +(defcustom lsp-ruff-log-level "error" |
53 | 54 | "Tracing level."
|
54 | 55 | :type '(choice (const "debug")
|
55 | 56 | (const "error")
|
56 | 57 | (const "info")
|
57 | 58 | (const "off")
|
58 | 59 | (const "warn"))
|
59 |
| - :group 'lsp-ruff-lsp) |
| 60 | + :group 'lsp-ruff) |
60 | 61 |
|
61 |
| -(defcustom lsp-ruff-lsp-python-path "python3" |
| 62 | +(defcustom lsp-ruff-python-path "python3" |
62 | 63 | "Path to the Python interpreter."
|
63 | 64 | :risky t
|
64 | 65 | :type 'string
|
65 |
| - :group 'lsp-ruff-lsp) |
| 66 | + :group 'lsp-ruff) |
66 | 67 |
|
67 |
| -(defcustom lsp-ruff-lsp-show-notifications "off" |
| 68 | +(defcustom lsp-ruff-show-notifications "off" |
68 | 69 | "When notifications are shown."
|
69 | 70 | :type '(choice (const "off")
|
70 | 71 | (const "onError")
|
71 | 72 | (const "onWarning")
|
72 | 73 | (const "always"))
|
73 |
| - :group 'lsp-ruff-lsp) |
| 74 | + :group 'lsp-ruff) |
74 | 75 |
|
75 |
| -(defcustom lsp-ruff-lsp-advertize-organize-imports t |
| 76 | +(defcustom lsp-ruff-advertize-organize-imports t |
76 | 77 | "Whether to report ability to handle source.organizeImports actions."
|
77 | 78 | :type 'boolean
|
78 |
| - :group 'lsp-ruff-lsp) |
| 79 | + :group 'lsp-ruff) |
79 | 80 |
|
80 |
| -(defcustom lsp-ruff-lsp-advertize-fix-all t |
| 81 | +(defcustom lsp-ruff-advertize-fix-all t |
81 | 82 | "Whether to report ability to handle source.fixAll actions."
|
82 | 83 | :type 'boolean
|
83 |
| - :group 'lsp-ruff-lsp) |
| 84 | + :group 'lsp-ruff) |
84 | 85 |
|
85 |
| -(defcustom lsp-ruff-lsp-import-strategy "fromEnvironment" |
86 |
| - "Where ruff is imported from if lsp-ruff-lsp-ruff-path is not set." |
| 86 | +(defcustom lsp-ruff-import-strategy "fromEnvironment" |
| 87 | + "Where ruff is imported from if lsp-ruff-ruff-path is not set." |
87 | 88 | :type '(choice (const "fromEnvironment")
|
88 | 89 | (const "useBundled"))
|
89 |
| - :group 'lsp-ruff-lsp) |
| 90 | + :group 'lsp-ruff) |
90 | 91 |
|
91 | 92 |
|
92 | 93 | (lsp-register-client
|
93 | 94 | (make-lsp-client
|
94 | 95 | :new-connection (lsp-stdio-connection
|
95 |
| - (lambda () lsp-ruff-lsp-server-command)) |
| 96 | + (lambda () lsp-ruff-server-command)) |
96 | 97 | :activation-fn (lsp-activate-on "python")
|
97 |
| - :server-id 'ruff-lsp |
| 98 | + :server-id 'ruff |
98 | 99 | :priority -2
|
99 | 100 | :add-on? t
|
100 | 101 | :initialization-options
|
101 | 102 | (lambda ()
|
102 | 103 | (list :settings
|
103 |
| - (list :args lsp-ruff-lsp-ruff-args |
104 |
| - :logLevel lsp-ruff-lsp-log-level |
105 |
| - :path lsp-ruff-lsp-ruff-path |
106 |
| - :interpreter (vector lsp-ruff-lsp-python-path) |
107 |
| - :showNotifications lsp-ruff-lsp-show-notifications |
108 |
| - :organizeImports (lsp-json-bool lsp-ruff-lsp-advertize-organize-imports) |
109 |
| - :fixAll (lsp-json-bool lsp-ruff-lsp-advertize-fix-all) |
110 |
| - :importStrategy lsp-ruff-lsp-import-strategy))))) |
111 |
| - |
112 |
| -(lsp-consistency-check lsp-ruff-lsp) |
113 |
| - |
114 |
| -(provide 'lsp-ruff-lsp) |
115 |
| -;;; lsp-ruff-lsp.el ends here |
| 104 | + (list :args lsp-ruff-ruff-args |
| 105 | + :logLevel lsp-ruff-log-level |
| 106 | + :path lsp-ruff-ruff-path |
| 107 | + :interpreter (vector lsp-ruff-python-path) |
| 108 | + :showNotifications lsp-ruff-show-notifications |
| 109 | + :organizeImports (lsp-json-bool lsp-ruff-advertize-organize-imports) |
| 110 | + :fixAll (lsp-json-bool lsp-ruff-advertize-fix-all) |
| 111 | + :importStrategy lsp-ruff-import-strategy))))) |
| 112 | + |
| 113 | +(lsp-consistency-check lsp-ruff) |
| 114 | + |
| 115 | +(provide 'lsp-ruff) |
| 116 | +;;; lsp-ruff.el ends here |
0 commit comments