A simple VIM plugin for Ruff
Ruff has already great integration with VIM via ALE and CoC. But for that you also need to configure those plugins, select a LSP and if you make an error, it's difficult to figure out what went wrong and your VIM might not be usable unless you fix the errors. I don't want to deal with that.
This plugin has been heavily inspired by Black's plugin and Black's plugin
does not need any special configuration, no LSPs, etc. You just install the plugin
and you do :Black
. I wanted something like this for Ruff, install the plugin
and just do :Ruff
.
To install with vim-plug:
Add to your configuration:
Plug 'shaoran/vim-ruff'
and execute :PlugInstall
.
The following variables can be specified:
Variable | Default value | Description |
---|---|---|
g:vimruff_ruff_path |
- | Path to the ruff binary |
g:vimruff_default |
"format" |
The default command |
g:vimruff_check_select |
- | --select argument for ruff check |
g:vimruff_eval_pyproject_toml |
v:true |
Evaluate the pyproject.toml file |
Path to the ruff
binary. If this variable is not set, then the PATH
environment variable is evaluated to find the path to the ruff
binary.
The :Ruff
command supports the format
and check
commands. This variable
sets the default command to execute when :Ruff
without arguments.
The values for this variable are:
"format"
"check"
"both"
(firstcheck --fix
is executed and thenformat
)
The --select
argument for ruff check --fix
If set then this plugin will evaluate the pyproject.toml
file (relative
to the current buffer). You can use the pyproject.toml
file to override
g:vimruff_default
, g:vimruff_check_select
and g:vimruff_ruff_path
variables. This allows you to have different settings per project.
Example:
[tool.vimruff.config]
default = "both"
check-select = "I"
ruff-path = "/opt/tools/ruff"
TODO: write me