diff --git a/README.md b/README.md index cd7c150..1df80ee 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ - [x] [prettier](https://github.com/prettier/prettier) - [ ] [rubocop](https://github.com/rubocop/rubocop) - [x] [rustfmt](https://github.com/rust-lang/rustfmt) +- [x] [taplo](https://github.com/tamasfe/taplo) - [ ] [shfmt](https://github.com/mvdan/sh) - [x] [stylua](https://github.com/JohnnyMorganz/StyLua) - [ ] [swiftformat](https://github.com/nicklockwood/SwiftFormat) @@ -37,7 +38,6 @@ - [x] [ruff](https://github.com/astral-sh/ruff) as `ruff format` - [x] [ruff_fix](https://github.com/astral-sh/ruff) as `ruff --fix` - ## Linters - [x] [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) diff --git a/lua/guard-collection/formatter.lua b/lua/guard-collection/formatter.lua index c66dd9f..8670174 100644 --- a/lua/guard-collection/formatter.lua +++ b/lua/guard-collection/formatter.lua @@ -132,6 +132,12 @@ M.rustfmt = { stdin = true, } +M.taplo = { + cmd = 'taplo', + args = { 'format', '-' }, + stdin = true, +} + M.shfmt = { cmd = 'shfmt', stdin = true, diff --git a/test/formatter/taplo_spec.lua b/test/formatter/taplo_spec.lua new file mode 100644 index 0000000..cc6eb64 --- /dev/null +++ b/test/formatter/taplo_spec.lua @@ -0,0 +1,24 @@ +describe('taplo', function() + it('can format', function() + local ft = require('guard.filetype') + ft('toml'):fmt('taplo') + require('guard').setup() + + local formatted = require('test.formatter.helper').test_with('toml', { + [[ [dependencies] ]], + [[ async-process = "^1.7"]], + [[strum = { version = "^0.25", features = ["derive"] } ]], + [[anyhow = "1" ]], + [[tracing-error = "0.2" ]], + [[]], + [[]] + }) + assert.are.same({ + "[dependencies]", + [[async-process = "^1.7"]], + [[strum = { version = "^0.25", features = ["derive"] }]], + [[anyhow = "1"]], + [[tracing-error = "0.2"]], + }, formatted) + end) +end) diff --git a/test/setup.sh b/test/setup.sh index 45e34b9..afbdb92 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -10,7 +10,7 @@ luarocks install luacheck & go install github.com/segmentio/golines@latest & pip -qqq install autopep8 black djhtml flake8 isort pylint yapf codespell ruff & npm install -g --silent \ - prettier @fsouza/prettierd sql-formatter shellcheck shfmt & + prettier @fsouza/prettierd sql-formatter shellcheck shfmt @taplo/cli & gem install -q rubocop & # Block, homebrew takes the longest time brew install \