Skip to content

Commit

Permalink
Python ruff formatter (#484)
Browse files Browse the repository at this point in the history
Add python ruff formatter support

https://github.com/astral-sh/ruff
  • Loading branch information
airreality authored Nov 22, 2023
1 parent e5fe7e8 commit afbc055
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ that caused Neoformat to be invoked.
[`pydevf`](https://github.com/fabioz/PyDev.Formatter),
[`isort`](https://github.com/timothycrosley/isort),
[`docformatter`](https://github.com/myint/docformatter),
[`pyment`](https://github.com/dadadel/pyment)
[`pyment`](https://github.com/dadadel/pyment),
[`ruff`](https://github.com/astral-sh/ruff)
- R
- [`styler`](https://github.com/r-lib/styler),
[`formatR`](https://github.com/yihui/formatR)
Expand Down
10 changes: 9 additions & 1 deletion autoload/neoformat/formatters/python.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function! neoformat#formatters#python#enabled() abort
return ['yapf', 'autopep8', 'black', 'isort', 'docformatter', 'pyment', 'pydevf']
return ['yapf', 'autopep8', 'black', 'isort', 'docformatter', 'pyment', 'pydevf', 'ruff']
endfunction

function! neoformat#formatters#python#yapf() abort
Expand Down Expand Up @@ -58,3 +58,11 @@ function! neoformat#formatters#python#pydevf() abort
\ 'replace': 1,
\ }
endfunction

function! neoformat#formatters#python#ruff() abort
return {
\ 'exe': 'ruff',
\ 'stdin': 1,
\ 'args': ['format', '-q', '-'],
\ }
endfunction
3 changes: 2 additions & 1 deletion doc/neoformat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
[`pydevf`](https://github.com/fabioz/PyDev.Formatter),
[`isort`](https://github.com/timothycrosley/isort),
[`docformatter`](https://github.com/myint/docformatter),
[`pyment`](https://github.com/dadadel/pyment)
[`pyment`](https://github.com/dadadel/pyment),
[`ruff`](https://github.com/astral-sh/ruff)
- R
- [`styler`](https://github.com/r-lib/styler),
[`formatR`](https://github.com/yihui/formatR)
Expand Down

0 comments on commit afbc055

Please sign in to comment.