Skip to content

Commit dbf13a3

Browse files
Add configuration options for python-lsp-ruff (#4345)
Add configuration options for python-lsp-ruff, documented at https://github.com/python-lsp/python-lsp-ruff#configuration.
1 parent 9d3ff6f commit dbf13a3

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

clients/lsp-pylsp.el

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,98 @@ Requires pylsp >= 0.33.0"
356356
:type 'boolean
357357
:group 'lsp-pylsp)
358358

359+
;; See https://github.com/python-lsp/python-lsp-ruff#configuration
360+
361+
(defcustom lsp-pylsp-plugins-ruff-enabled nil
362+
"Enable or disable the plugin."
363+
:type 'boolean
364+
:group 'lsp-pylsp)
365+
366+
(defcustom lsp-pylsp-plugins-ruff-executable nil
367+
"Custom path to ruff."
368+
:type 'file
369+
:group 'lsp-pylsp)
370+
371+
(defcustom lsp-pylsp-plugins-ruff-config nil
372+
"Custom config for ruff to use."
373+
:type 'file
374+
:group 'lsp-pylsp)
375+
376+
(defcustom lsp-pylsp-plugins-ruff-extend-select nil
377+
"Rules that are additionally used by ruff."
378+
:type 'lsp-string-vector
379+
:group 'lsp-pylsp)
380+
381+
(defcustom lsp-pylsp-plugins-ruff-extend-ignore nil
382+
"Rules that are additionally ignored by ruff."
383+
:type 'lsp-string-vector
384+
:group 'lsp-pylsp)
385+
386+
(defcustom lsp-pylsp-plugins-ruff-format nil
387+
"Rules that are marked as fixable by ruff that should be fixed when running textDocument/formatting."
388+
:type 'lsp-string-vector
389+
:group 'lsp-pylsp)
390+
391+
(defcustom lsp-pylsp-plugins-ruff-severities nil
392+
"Optional table of rules where a custom severity is desired."
393+
:type '(alist :key-type (lsp-string-vector :tag "rules") :value-type (string :tag "severity"))
394+
:group 'lsp-pylsp)
395+
396+
(defcustom lsp-pylsp-plugins-ruff-unsafe-fixes nil
397+
"Whether or not to offer unsafe fixes as code actions. Ignored with the \"Fix All\" action."
398+
:type 'boolean
399+
:group 'lsp-pylsp)
400+
401+
;; Rules that are ignored when a pyproject.toml or ruff.toml is present
402+
(defcustom lsp-pylsp-plugins-ruff-line-length 88
403+
"Line length to pass to ruff checking and formatting.
404+
405+
Note this variable will be ignored when a when a pyproject.toml or ruff.toml is present."
406+
:type 'integer
407+
:group 'lsp-pylsp)
408+
409+
(defcustom lsp-pylsp-plugins-ruff-exclude nil
410+
"Files to be excluded by ruff checking.
411+
412+
Note this variable will be ignored when a when a pyproject.toml or ruff.toml is present."
413+
:type 'lsp-string-vector
414+
:group 'lsp-pylsp)
415+
416+
(defcustom lsp-pylsp-plugins-ruff-select nil
417+
"Rules to be enabled by ruff.
418+
419+
Note this variable will be ignored when a when a pyproject.toml or ruff.toml is present."
420+
:type 'lsp-string-vector
421+
:group 'lsp-pylsp)
422+
423+
(defcustom lsp-pylsp-plugins-ruff-ignore nil
424+
"Rules to be ignored by ruff.
425+
426+
Note this variable will be ignored when a when a pyproject.toml or ruff.toml is present."
427+
:type 'lsp-string-vector
428+
:group 'lsp-pylsp)
429+
430+
(defcustom lsp-pylsp-plugins-ruff-per-file-ignores nil
431+
"Rules that should be ignored for specific files.
432+
433+
Note this variable will be ignored when a when a pyproject.toml or ruff.toml is present."
434+
:type '(alist :key-type (lsp-string-vector :tag "files") :value-type (string :tag "rule"))
435+
:group 'lsp-pylsp)
436+
437+
(defcustom lsp-pylsp-plugins-ruff-preview nil
438+
"Whether to enable the preview style linting and formatting.
439+
440+
Note this variable will be ignored when a when a pyproject.toml or ruff.toml is present."
441+
:type 'boolean
442+
:group 'lsp-pylsp)
443+
444+
(defcustom lsp-pylsp-plugins-ruff-target-version nil
445+
"The minimum python version to target (applies for both linting and formatting).
446+
447+
Note this variable will be ignored when a when a pyproject.toml or ruff.toml is present."
448+
:type 'string
449+
:group 'lsp-pylsp)
450+
359451
(defcustom lsp-pylsp-rename-backend 'jedi
360452
"Choose renaming backend.
361453
@@ -433,6 +525,21 @@ So it will rename only references it can find."
433525
("pylsp.plugins.preload.enabled" lsp-pylsp-plugins-preload-enabled t)
434526
("pylsp.plugins.mccabe.threshold" lsp-pylsp-plugins-mccabe-threshold)
435527
("pylsp.plugins.mccabe.enabled" lsp-pylsp-plugins-mccabe-enabled t)
528+
("pylsp.plugins.ruff.enabled" lsp-pylsp-plugins-ruff-enabled t)
529+
("pylsp.plugins.ruff.executable" lsp-pylsp-plugins-ruff-executable)
530+
("pylsp.plugins.ruff.config" lsp-pylsp-plugins-ruff-config)
531+
("pylsp.plugins.ruff.extendSelect" lsp-pylsp-plugins-ruff-extend-select)
532+
("pylsp.plugins.ruff.extendIgnore" lsp-pylsp-plugins-ruff-extend-ignore)
533+
("pylsp.plugins.ruff.format" lsp-pylsp-plugins-ruff-format)
534+
("pylsp.plugins.ruff.severities" lsp-pylsp-plugins-ruff-severities)
535+
("pylsp.plugins.ruff.unsafeFixes" lsp-pylsp-plugins-ruff-unsafe-fixes t)
536+
("pylsp.plugins.ruff.lineLength" lsp-pylsp-plugins-ruff-line-length)
537+
("pylsp.plugins.ruff.exclude" lsp-pylsp-plugins-ruff-exclude)
538+
("pylsp.plugins.ruff.select" lsp-pylsp-plugins-ruff-select)
539+
("pylsp.plugins.ruff.ignore" lsp-pylsp-plugins-ruff-ignore)
540+
("pylsp.plugins.ruff.perFileIgnores" lsp-pylsp-plugins-ruff-per-file-ignores)
541+
("pylsp.plugins.ruff.preview" lsp-pylsp-plugins-ruff-preview t)
542+
("pylsp.plugins.ruff.targetVersion" lsp-pylsp-plugins-ruff-target-version)
436543
("pylsp.plugins.jedi_symbols.all_scopes" lsp-pylsp-plugins-jedi-symbols-all-scopes t)
437544
("pylsp.plugins.jedi_symbols.enabled" lsp-pylsp-plugins-jedi-symbols-enabled t)
438545
("pylsp.plugins.jedi_signature_help.enabled" lsp-pylsp-plugins-jedi-signature-help-enabled t)

0 commit comments

Comments
 (0)