diff options
author | Frederik Buchlák <30214087+fbuchlak@users.noreply.github.com> | 2023-10-30 18:10:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 11:10:25 -0700 |
commit | f7766d2fbe23f0f22a3db1513beba7d03a8dc261 (patch) | |
tree | 0f40c86a6eda496b99120a3c30926c6b15014f7c | |
parent | 3d639d6155a63e3143920b739cee02f3faa1b4db (diff) |
feat: add usort (#167)
* feat: add usort
* formatting via stdin
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | doc/conform.txt | 1 | ||||
-rw-r--r-- | lua/conform/formatters/usort.lua | 15 |
3 files changed, 17 insertions, 0 deletions
@@ -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. diff --git a/doc/conform.txt b/doc/conform.txt index 6c7a68f..ae5db5e 100644 --- a/doc/conform.txt +++ b/doc/conform.txt @@ -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. diff --git a/lua/conform/formatters/usort.lua b/lua/conform/formatters/usort.lua new file mode 100644 index 0000000..f2a141a --- /dev/null +++ b/lua/conform/formatters/usort.lua @@ -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", + }), +} |