diff options
Diffstat (limited to 'lua/conform/formatters')
39 files changed, 409 insertions, 0 deletions
diff --git a/lua/conform/formatters/autoflake.lua b/lua/conform/formatters/autoflake.lua new file mode 100644 index 0000000..04daf71 --- /dev/null +++ b/lua/conform/formatters/autoflake.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/PyCQA/autoflake", + description = "Removes unused imports and unused variables as reported by pyflakes.", + }, + command = "autoflake", + args = { "--stdin-display-name", "$FILENAME", "-" }, +} diff --git a/lua/conform/formatters/autopep8.lua b/lua/conform/formatters/autopep8.lua new file mode 100644 index 0000000..5ed2f83 --- /dev/null +++ b/lua/conform/formatters/autopep8.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/hhatto/autopep8", + description = "A tool that automatically formats Python code to conform to the PEP 8 style guide.", + }, + command = "autopep8", + args = { "-" }, +} diff --git a/lua/conform/formatters/black.lua b/lua/conform/formatters/black.lua new file mode 100644 index 0000000..0d892a2 --- /dev/null +++ b/lua/conform/formatters/black.lua @@ -0,0 +1,19 @@ +local util = require("conform.util") +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/psf/black", + description = "The uncompromising Python code formatter.", + }, + command = "black", + args = { + "--stdin-filename", + "$FILENAME", + "--quiet", + "-", + }, + cwd = util.root_file({ + -- https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file + "pyproject.toml", + }), +} diff --git a/lua/conform/formatters/clang_format.lua b/lua/conform/formatters/clang_format.lua new file mode 100644 index 0000000..d2c6d41 --- /dev/null +++ b/lua/conform/formatters/clang_format.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://www.kernel.org/doc/html/latest/process/clang-format.html", + description = "Tool to format C/C++/… code according to a set of rules and heuristics.", + }, + command = "clang-format", + args = { "-assume-filename", "$FILENAME" }, +} diff --git a/lua/conform/formatters/cljstyle.lua b/lua/conform/formatters/cljstyle.lua new file mode 100644 index 0000000..ffd8061 --- /dev/null +++ b/lua/conform/formatters/cljstyle.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/greglook/cljstyle", + description = "Formatter for Clojure code.", + }, + command = "cljstyle", + args = { "pipe" }, +} diff --git a/lua/conform/formatters/cmake_format.lua b/lua/conform/formatters/cmake_format.lua new file mode 100644 index 0000000..563bcae --- /dev/null +++ b/lua/conform/formatters/cmake_format.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/cheshirekow/cmake_format", + description = "Parse cmake listfiles and format them nicely.", + }, + command = "cmake-format", + args = { "-" }, +} diff --git a/lua/conform/formatters/dart_format.lua b/lua/conform/formatters/dart_format.lua new file mode 100644 index 0000000..eb9b39c --- /dev/null +++ b/lua/conform/formatters/dart_format.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://dart.dev/tools/dart-format", + description = "Replace the whitespace in your program with formatting that follows Dart guidelines.", + }, + command = "dart", + args = { "format" }, +} diff --git a/lua/conform/formatters/dfmt.lua b/lua/conform/formatters/dfmt.lua new file mode 100644 index 0000000..49c99cb --- /dev/null +++ b/lua/conform/formatters/dfmt.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/dlang-community/dfmt", + description = "Formatter for D source code.", + }, + command = "dfmt", +} diff --git a/lua/conform/formatters/elm_format.lua b/lua/conform/formatters/elm_format.lua new file mode 100644 index 0000000..23f1408 --- /dev/null +++ b/lua/conform/formatters/elm_format.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/avh4/elm-format", + description = "elm-format formats Elm source code according to a standard set of rules based on the official [Elm Style Guide](https://elm-lang.org/docs/style-guide).", + }, + command = "elm-format", + args = { "--stdin" }, +} diff --git a/lua/conform/formatters/erb_format.lua b/lua/conform/formatters/erb_format.lua new file mode 100644 index 0000000..dad08ca --- /dev/null +++ b/lua/conform/formatters/erb_format.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/nebulab/erb-formatter", + description = "Format ERB files with speed and precision.", + }, + command = "erb-format", + args = { "--stdin" }, +} diff --git a/lua/conform/formatters/eslint_d.lua b/lua/conform/formatters/eslint_d.lua new file mode 100644 index 0000000..e036aae --- /dev/null +++ b/lua/conform/formatters/eslint_d.lua @@ -0,0 +1,13 @@ +local util = require("conform.util") +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/mantoni/eslint_d.js/", + description = "Like ESLint, but faster.", + }, + command = util.from_node_modules("eslint_d"), + args = { "--fix-to-stdout", "--stdin", "--stdin-filename", "$FILENAME" }, + cwd = util.root_file({ + "package.json", + }), +} diff --git a/lua/conform/formatters/gdformat.lua b/lua/conform/formatters/gdformat.lua new file mode 100644 index 0000000..914bb89 --- /dev/null +++ b/lua/conform/formatters/gdformat.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/Scony/godot-gdscript-toolkit", + description = "A formatter for Godot's gdscript.", + }, + command = "gdformat", + args = { "-" }, +} diff --git a/lua/conform/formatters/gofmt.lua b/lua/conform/formatters/gofmt.lua new file mode 100644 index 0000000..b0b81c3 --- /dev/null +++ b/lua/conform/formatters/gofmt.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://pkg.go.dev/cmd/gofmt", + description = "Formats go programs.", + }, + command = "gofmt", +} diff --git a/lua/conform/formatters/gofumpt.lua b/lua/conform/formatters/gofumpt.lua new file mode 100644 index 0000000..79fb4dc --- /dev/null +++ b/lua/conform/formatters/gofumpt.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/mvdan/gofumpt", + description = "Enforce a stricter format than gofmt, while being backwards compatible. That is, gofumpt is happy with a subset of the formats that gofmt is happy with.", + }, + command = "gofumpt", +} diff --git a/lua/conform/formatters/goimports.lua b/lua/conform/formatters/goimports.lua new file mode 100644 index 0000000..2361e43 --- /dev/null +++ b/lua/conform/formatters/goimports.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://pkg.go.dev/golang.org/x/tools/cmd/goimports", + description = "Updates your Go import lines, adding missing ones and removing unreferenced ones.", + }, + command = "goimports", + args = { "-srcdir", "$DIRNAME" }, +} diff --git a/lua/conform/formatters/htmlbeautifier.lua b/lua/conform/formatters/htmlbeautifier.lua new file mode 100644 index 0000000..3182f99 --- /dev/null +++ b/lua/conform/formatters/htmlbeautifier.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/threedaymonk/htmlbeautifier", + description = "A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.", + }, + command = "htmlbeautifier", +} diff --git a/lua/conform/formatters/isort.lua b/lua/conform/formatters/isort.lua new file mode 100644 index 0000000..f6c6e3d --- /dev/null +++ b/lua/conform/formatters/isort.lua @@ -0,0 +1,24 @@ +local util = require("conform.util") +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/PyCQA/isort", + description = "Python utility / library to sort imports alphabetically and automatically separate them into sections and by type.", + }, + command = "isort", + args = { + "--stdout", + "--filename", + "$FILENAME", + "-", + }, + cwd = util.root_file({ + -- https://pycqa.github.io/isort/docs/configuration/config_files.html + ".isort.cfg", + "pyproject.toml", + "setup.py", + "setup.cfg", + "tox.ini", + ".editorconfig", + }), +} diff --git a/lua/conform/formatters/jq.lua b/lua/conform/formatters/jq.lua new file mode 100644 index 0000000..50a905d --- /dev/null +++ b/lua/conform/formatters/jq.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/stedolan/jq", + description = "Command-line JSON processor.", + }, + command = "jq", +} diff --git a/lua/conform/formatters/nixfmt.lua b/lua/conform/formatters/nixfmt.lua new file mode 100644 index 0000000..6c5001a --- /dev/null +++ b/lua/conform/formatters/nixfmt.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/serokell/nixfmt", + description = "nixfmt is a formatter for Nix code, intended to apply a uniform style.", + }, + command = "nixfmt", +} diff --git a/lua/conform/formatters/nixpkgs_fmt.lua b/lua/conform/formatters/nixpkgs_fmt.lua new file mode 100644 index 0000000..6685fe8 --- /dev/null +++ b/lua/conform/formatters/nixpkgs_fmt.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/nix-community/nixpkgs-fmt", + description = "nixpkgs-fmt is a Nix code formatter for nixpkgs.", + }, + command = "nixpkgs-fmt", +} diff --git a/lua/conform/formatters/ocamlformat.lua b/lua/conform/formatters/ocamlformat.lua new file mode 100644 index 0000000..4ea1b49 --- /dev/null +++ b/lua/conform/formatters/ocamlformat.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/ocaml-ppx/ocamlformat", + description = "Auto-formatter for OCaml code.", + }, + command = "ocamlformat", + args = { "--enable-outside-detected-project", "--name", "$FILENAME", "-" }, +} diff --git a/lua/conform/formatters/pg_format.lua b/lua/conform/formatters/pg_format.lua new file mode 100644 index 0000000..87aff66 --- /dev/null +++ b/lua/conform/formatters/pg_format.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/darold/pgFormatter", + description = "PostgreSQL SQL syntax beautifier.", + }, + command = "pg_format", +} diff --git a/lua/conform/formatters/prettier.lua b/lua/conform/formatters/prettier.lua new file mode 100644 index 0000000..6f4bbfb --- /dev/null +++ b/lua/conform/formatters/prettier.lua @@ -0,0 +1,24 @@ +local util = require("conform.util") +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/prettier/prettier", + description = [[Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.]], + }, + command = util.from_node_modules("prettier"), + args = { "--stdin-filepath", "$FILENAME" }, + cwd = util.root_file({ + -- https://prettier.io/docs/en/configuration.html + ".prettierrc", + ".prettierrc.json", + ".prettierrc.yml", + ".prettierrc.yaml", + ".prettierrc.json5", + ".prettierrc.js", + ".prettierrc.cjs", + ".prettierrc.toml", + "prettier.config.js", + "prettier.config.cjs", + "package.json", + }), +} diff --git a/lua/conform/formatters/prettierd.lua b/lua/conform/formatters/prettierd.lua new file mode 100644 index 0000000..0af6baf --- /dev/null +++ b/lua/conform/formatters/prettierd.lua @@ -0,0 +1,24 @@ +local util = require("conform.util") +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/fsouza/prettierd", + description = "prettier, as a daemon, for ludicrous formatting speed.", + }, + command = util.from_node_modules("prettierd"), + args = { "$FILENAME" }, + cwd = util.root_file({ + -- https://prettier.io/docs/en/configuration.html + ".prettierrc", + ".prettierrc.json", + ".prettierrc.yml", + ".prettierrc.yaml", + ".prettierrc.json5", + ".prettierrc.js", + ".prettierrc.cjs", + ".prettierrc.toml", + "prettier.config.js", + "prettier.config.cjs", + "package.json", + }), +} diff --git a/lua/conform/formatters/rubocop.lua b/lua/conform/formatters/rubocop.lua new file mode 100644 index 0000000..492f379 --- /dev/null +++ b/lua/conform/formatters/rubocop.lua @@ -0,0 +1,16 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/rubocop/rubocop", + description = "Ruby static code analyzer and formatter, based on the community Ruby style guide.", + }, + command = "rubocop", + args = { + "-a", + "-f", + "quiet", + "--stderr", + "--stdin", + "$FILENAME", + }, +} diff --git a/lua/conform/formatters/rustfmt.lua b/lua/conform/formatters/rustfmt.lua new file mode 100644 index 0000000..7b5e322 --- /dev/null +++ b/lua/conform/formatters/rustfmt.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/rust-lang/rustfmt", + description = "A tool for formatting rust code according to style guidelines.", + }, + command = "rustfmt", + args = { "--emit=stdout" }, +} diff --git a/lua/conform/formatters/scalafmt.lua b/lua/conform/formatters/scalafmt.lua new file mode 100644 index 0000000..2b9e451 --- /dev/null +++ b/lua/conform/formatters/scalafmt.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/scalameta/scalafmt", + description = "Code formatter for Scala.", + }, + command = "scalafmt", + args = { "--stdin" }, +} diff --git a/lua/conform/formatters/shfmt.lua b/lua/conform/formatters/shfmt.lua new file mode 100644 index 0000000..6e40f0c --- /dev/null +++ b/lua/conform/formatters/shfmt.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/mvdan/sh", + description = "A shell parser, formatter, and interpreter with `bash` support.", + }, + command = "shfmt", + args = { "-filename", "$FILENAME" }, +} diff --git a/lua/conform/formatters/sql_formatter.lua b/lua/conform/formatters/sql_formatter.lua new file mode 100644 index 0000000..bd92851 --- /dev/null +++ b/lua/conform/formatters/sql_formatter.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/sql-formatter-org/sql-formatter", + description = "A whitespace formatter for different query languages.", + }, + command = "sql-formatter", +} diff --git a/lua/conform/formatters/stylua.lua b/lua/conform/formatters/stylua.lua new file mode 100644 index 0000000..f2cc412 --- /dev/null +++ b/lua/conform/formatters/stylua.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/JohnnyMorganz/StyLua", + description = "An opinionated code formatter for Lua.", + }, + command = "stylua", + args = { "--search-parent-directories", "--stdin-filepath", "$FILENAME", "-" }, +} diff --git a/lua/conform/formatters/swift_format.lua b/lua/conform/formatters/swift_format.lua new file mode 100644 index 0000000..2b81297 --- /dev/null +++ b/lua/conform/formatters/swift_format.lua @@ -0,0 +1,8 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/apple/swift-format", + description = "Swift formatter from apple. Requires building from source with `swift build`.", + }, + command = "swift-format", +} diff --git a/lua/conform/formatters/swiftformat.lua b/lua/conform/formatters/swiftformat.lua new file mode 100644 index 0000000..821a010 --- /dev/null +++ b/lua/conform/formatters/swiftformat.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/nicklockwood/SwiftFormat", + description = "SwiftFormat is a code library and command-line tool for reformatting `swift` code on macOS or Linux.", + }, + command = "swiftformat", + args = { "--stdinpath", "$FILENAME" }, +} diff --git a/lua/conform/formatters/terraform_fmt.lua b/lua/conform/formatters/terraform_fmt.lua new file mode 100644 index 0000000..44edc55 --- /dev/null +++ b/lua/conform/formatters/terraform_fmt.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://www.terraform.io/docs/cli/commands/fmt.html", + description = "The terraform-fmt command rewrites `terraform` configuration files to a canonical format and style.", + }, + command = "terraform", + args = { "fmt", "-" }, +} diff --git a/lua/conform/formatters/uncrustify.lua b/lua/conform/formatters/uncrustify.lua new file mode 100644 index 0000000..3430063 --- /dev/null +++ b/lua/conform/formatters/uncrustify.lua @@ -0,0 +1,11 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/uncrustify/uncrustify", + description = "A source code beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and Vala.", + }, + command = "uncrustify", + args = function(ctx) + return { "-q", "-l", vim.bo[ctx.buf].filetype:upper() } + end, +} diff --git a/lua/conform/formatters/xmlformat.lua b/lua/conform/formatters/xmlformat.lua new file mode 100644 index 0000000..25b48e2 --- /dev/null +++ b/lua/conform/formatters/xmlformat.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/pamoller/xmlformatter", + description = "xmlformatter is an Open Source Python package, which provides formatting of XML documents.", + }, + command = "xmlformat", + args = { "-" }, +} diff --git a/lua/conform/formatters/yamlfix.lua b/lua/conform/formatters/yamlfix.lua new file mode 100644 index 0000000..1b00e01 --- /dev/null +++ b/lua/conform/formatters/yamlfix.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/lyz-code/yamlfix", + description = "A configurable YAML formatter that keeps comments.", + }, + command = "yamlfix", + args = { "-" }, +} diff --git a/lua/conform/formatters/yamlfmt.lua b/lua/conform/formatters/yamlfmt.lua new file mode 100644 index 0000000..56c6cb6 --- /dev/null +++ b/lua/conform/formatters/yamlfmt.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/google/yamlfmt", + description = "yamlfmt is an extensible command line tool or library to format yaml files.", + }, + command = "yamlfmt", + args = { "-" }, +} diff --git a/lua/conform/formatters/yapf.lua b/lua/conform/formatters/yapf.lua new file mode 100644 index 0000000..5d7e866 --- /dev/null +++ b/lua/conform/formatters/yapf.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/google/yapf", + description = "Yet Another Python Formatter.", + }, + command = "yapf", + args = { "--quiet" }, +} diff --git a/lua/conform/formatters/zigfmt.lua b/lua/conform/formatters/zigfmt.lua new file mode 100644 index 0000000..9c93c0b --- /dev/null +++ b/lua/conform/formatters/zigfmt.lua @@ -0,0 +1,9 @@ +---@type conform.FormatterConfig +return { + meta = { + url = "https://github.com/ziglang/zig", + description = "Reformat Zig source into canonical form.", + }, + command = "zig", + args = { "fmt", "--stdin" }, +} |