diff --git a/docs/editors/setup.md b/docs/editors/setup.md index 507e9d450c461..f50f3abbd395d 100644 --- a/docs/editors/setup.md +++ b/docs/editors/setup.md @@ -131,6 +131,63 @@ To view the trace logs between Neovim and Ruff, set the log level for Neovim's L vim.lsp.set_log_level('debug') ``` +
+With the conform.nvim plugin for Neovim. + +```lua +require("conform").setup({ + formatters_by_ft = { + python = { + -- To fix auto-fixable lint errors. + "ruff_fix", + -- To run the Ruff formatter. + "ruff_format", + -- To organize the imports. + "ruff_organize_imports", + }, + }, +}) +``` + +
+ +
+With the nvim-lint plugin for Neovim. + +```lua +require("lint").linters_by_ft = { + python = { "ruff" }, +} +``` + +
+ +
+With the ALE plugin for Neovim or Vim. + +Neovim (using Lua): + +```lua +-- Linters +vim.g.ale_linters = { python = { "ruff" } } +-- Fixers +vim.g.ale_fixers = { python = { "ruff", "ruff_format" } } +``` + +Vim (using Vimscript): + +```vim +" Linters +let g:ale_linters = { "python": ["ruff"] } +" Fixers +let g:ale_fixers = { "python": ["ruff", "ruff_format"] } +``` + +For the fixers, ruff will run ruff check --fix (to fix all auto-fixable +problems) whereas ruff_format will run ruff format. + +
+ ## Vim The [`vim-lsp`](https://github.com/prabirshrestha/vim-lsp) plugin can be used to configure the Ruff Language Server in Vim. @@ -169,24 +226,8 @@ endfunction Ruff is also available as part of the [coc-pyright](https://github.com/fannheyward/coc-pyright) extension for [coc.nvim](https://github.com/neoclide/coc.nvim). -
-With the ALE plugin for Vim or Neovim. - -```vim -" Linters -let g:ale_linters = { "python": ["ruff"] } -" Fixers -let g:ale_fixers = { "python": ["ruff", "ruff_format"] } -``` - -For the fixers, `ruff` will run `ruff check --fix` (to fix all auto-fixable problems) whereas -`ruff_format` will run `ruff format`. - -
-
Ruff can also be integrated via efm language server in just a few lines. -
Following is an example config for efm to use Ruff for linting and formatting Python files: @@ -203,38 +244,6 @@ tools:
-
-With the conform.nvim plugin for Neovim. -
- -```lua -require("conform").setup({ - formatters_by_ft = { - python = { - -- To fix auto-fixable lint errors. - "ruff_fix", - -- To run the Ruff formatter. - "ruff_format", - -- To organize the imports. - "ruff_organize_imports", - }, - }, -}) -``` - -
- -
-With the nvim-lint plugin for Neovim. - -```lua -require("lint").linters_by_ft = { - python = { "ruff" }, -} -``` - -
- ## Helix Open the [language configuration file](https://docs.helix-editor.com/languages.html#languagestoml-files) for