vim-codefmt icon indicating copy to clipboard operation
vim-codefmt copied to clipboard

Add ruff as formatter for Python

Open Bidaya0 opened this issue 1 year ago • 3 comments

Formatter tool ruff

Filetype(s)

  • python

Additional context

Bidaya0 avatar Jul 21 '23 02:07 Bidaya0

Hadn't heard about ruff yet but it looks great!

As a formatter, do you know if

  • it has built-in support for range formatting (updating only a few target lines out of a file, plus whatever surrounding lines it needs to touch to make a complete valid formatting change)
  • its formatting decisions tend to be stable (avoid fighting with existing valid formatting when there are multiple valid ways to format a piece of code, such as a list that's short enough to fit on one line) ?

dbarnett avatar Jul 21 '23 13:07 dbarnett

@dbarnett As far as I know, ruff is more of a linter than a formatter. But because it has autofix support, it can also be regarded as a formatting tool (and it also have some rules related to code format).

  • Yes and no, ruff not support range formatting as a command line tool, but can support range formatting with ruff-lsp.
  • Yes, I think, as a linter, all rules that can be autofixed have only one way to autofix. So it not has "multiple valid ways to format a piece of code".

st1020 avatar Jul 24 '23 11:07 st1020

Hadn't heard about ruff yet but it looks great!

As a formatter, do you know if

  • it has built-in support for range formatting (updating only a few target lines out of a file, plus whatever surrounding lines it needs to touch to make a complete valid formatting change)
  • its formatting decisions tend to be stable (avoid fighting with existing valid formatting when there are multiple valid ways to format a piece of code, such as a list that's short enough to fit on one line) ?

Sorry for the late reply, the situation with the library is basically as described by st1020

  • For range formatting, I found a related issue in ruff-lsp, but there is no built-in implementation
  • yes, its formatting decisions tend to be stable .

Bidaya0 avatar Jul 26 '23 02:07 Bidaya0