Skip to content

Commit

Permalink
feat: add usort (#167)
Browse files Browse the repository at this point in the history
* feat: add usort

* formatting via stdin
  • Loading branch information
fbuchlak authored Oct 30, 2023
1 parent 3d639d6 commit f7766d2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ You can view this list in vim with `:help conform-formatters`
- [trim_newlines](https://www.gnu.org/software/gawk/manual/gawk.html) - Trim new lines with awk.
- [trim_whitespace](https://www.gnu.org/software/gawk/manual/gawk.html) - Trim whitespaces with awk.
- [uncrustify](https://github.com/uncrustify/uncrustify) - A source code beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and Vala.
- [usort](https://github.com/facebook/usort) - Safe, minimal import sorting for Python projects.
- [xmlformat](https://github.com/pamoller/xmlformatter) - xmlformatter is an Open Source Python package, which provides formatting of XML documents.
- [yamlfix](https://github.com/lyz-code/yamlfix) - A configurable YAML formatter that keeps comments.
- [yamlfmt](https://github.com/google/yamlfmt) - yamlfmt is an extensible command line tool or library to format yaml files.
Expand Down
1 change: 1 addition & 0 deletions doc/conform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ FORMATTERS *conform-formatter
`trim_whitespace` - Trim whitespaces with awk.
`uncrustify` - A source code beautifier for C, C++, C#, ObjectiveC, D, Java,
Pawn and Vala.
`usort` - Safe, minimal import sorting for Python projects.
`xmlformat` - xmlformatter is an Open Source Python package, which provides
formatting of XML documents.
`yamlfix` - A configurable YAML formatter that keeps comments.
Expand Down
15 changes: 15 additions & 0 deletions lua/conform/formatters/usort.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local util = require("conform.util")

---@type conform.FileFormatterConfig
return {
meta = {
url = "https://github.com/facebook/usort",
description = "Safe, minimal import sorting for Python projects.",
},
command = "usort",
args = { "format", "-" },
stdin = true,
cwd = util.root_file({
"pyproject.toml",
}),
}

0 comments on commit f7766d2

Please sign in to comment.