From 37a2d65bd2ee41540cc426d2cffef6d6f8648357 Mon Sep 17 00:00:00 2001 From: xfzv <78810647+xfzv@users.noreply.github.com> Date: Thu, 7 Sep 2023 19:29:08 +0000 Subject: feat: add beautysh, taplo, trim_newlines and trim_whitespace (#29) * feat: add beautysh * feat: add taplo * feat: add trim_newlines * feat: add trim_whitespace * doc: mention that `trim_newlines` and `trim_whitespaces` are using `awk` --------- Co-authored-by: xfzv <> --- README.md | 4 ++++ lua/conform/formatters/beautysh.lua | 9 +++++++++ lua/conform/formatters/taplo.lua | 9 +++++++++ lua/conform/formatters/trim_newlines.lua | 9 +++++++++ lua/conform/formatters/trim_whitespace.lua | 9 +++++++++ 5 files changed, 40 insertions(+) create mode 100644 lua/conform/formatters/beautysh.lua create mode 100644 lua/conform/formatters/taplo.lua create mode 100644 lua/conform/formatters/trim_newlines.lua create mode 100644 lua/conform/formatters/trim_whitespace.lua diff --git a/README.md b/README.md index f4657cb..8128927 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ To view configured and available formatters, as well as to see the path to the l - [autoflake](https://github.com/PyCQA/autoflake) - Removes unused imports and unused variables as reported by pyflakes. - [autopep8](https://github.com/hhatto/autopep8) - A tool that automatically formats Python code to conform to the PEP 8 style guide. +- [beautysh](https://github.com/lovesegfault/beautysh) - A Bash beautifier for the masses. - [black](https://github.com/psf/black) - The uncompromising Python code formatter. - [clang_format](https://www.kernel.org/doc/html/latest/process/clang-format.html) - Tool to format C/C++/… code according to a set of rules and heuristics. - [cljstyle](https://github.com/greglook/cljstyle) - Formatter for Clojure code. @@ -189,7 +190,10 @@ To view configured and available formatters, as well as to see the path to the l - [stylua](https://github.com/JohnnyMorganz/StyLua) - An opinionated code formatter for Lua. - [swift_format](https://github.com/apple/swift-format) - Swift formatter from apple. Requires building from source with `swift build`. - [swiftformat](https://github.com/nicklockwood/SwiftFormat) - SwiftFormat is a code library and command-line tool for reformatting `swift` code on macOS or Linux. +- [taplo](https://github.com/tamasfe/taplo) - A TOML toolkit written in Rust - [terraform_fmt](https://www.terraform.io/docs/cli/commands/fmt.html) - The terraform-fmt command rewrites `terraform` configuration files to a canonical format and style. +- [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. - [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. diff --git a/lua/conform/formatters/beautysh.lua b/lua/conform/formatters/beautysh.lua new file mode 100644 index 0000000..4fe1bc1 --- /dev/null +++ b/lua/conform/formatters/beautysh.lua @@ -0,0 +1,9 @@ +---@type conform.FileFormatterConfig +return { + meta = { + url = "https://github.com/lovesegfault/beautysh", + description = "A Bash beautifier for the masses.", + }, + command = "beautysh", + args = { "-" } +} diff --git a/lua/conform/formatters/taplo.lua b/lua/conform/formatters/taplo.lua new file mode 100644 index 0000000..675bed3 --- /dev/null +++ b/lua/conform/formatters/taplo.lua @@ -0,0 +1,9 @@ +---@type conform.FileFormatterConfig +return { + meta = { + url = "https://github.com/tamasfe/taplo", + description = "A TOML toolkit written in Rust", + }, + command = "taplo", + args = { "format", "-" }, +} diff --git a/lua/conform/formatters/trim_newlines.lua b/lua/conform/formatters/trim_newlines.lua new file mode 100644 index 0000000..4397ac7 --- /dev/null +++ b/lua/conform/formatters/trim_newlines.lua @@ -0,0 +1,9 @@ +---@type conform.FileFormatterConfig +return { + meta = { + url = "https://www.gnu.org/software/gawk/manual/gawk.html", + description = "Trim new lines with awk", + }, + command = "awk", + args = { 'NF{print s $0; s=""; next} {s=s ORS}' }, +} diff --git a/lua/conform/formatters/trim_whitespace.lua b/lua/conform/formatters/trim_whitespace.lua new file mode 100644 index 0000000..7178e0e --- /dev/null +++ b/lua/conform/formatters/trim_whitespace.lua @@ -0,0 +1,9 @@ +---@type conform.FileFormatterConfig +return { + meta = { + url = "https://www.gnu.org/software/gawk/manual/gawk.html", + description = "Trim whitespaces with awk", + }, + command = "awk", + args = { '{ sub(/[ \t]+$/, ""); print }' }, +} -- cgit v1.2.3-70-g09d2