aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--doc/conform.txt1
-rw-r--r--lua/conform/formatters/usort.lua15
3 files changed, 17 insertions, 0 deletions
diff --git a/README.md b/README.md
index bb087da..1d16903 100644
--- a/README.md
+++ b/README.md
@@ -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",
+ }),
+}