From 63c14c3f87fb7e4fe65f755bdc2005a38c136912 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Tue, 12 Sep 2023 18:29:10 +0200 Subject: [PATCH 1/4] Add dprint formatter --- README.md | 1 + lua/guard-collection/formatter.lua | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 350e2c3..a26a8d4 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ - [x] [cbfmt](https://github.com/lukas-reineke/cbfmt) - [x] [clang-format](https://www.kernel.org/doc/html/latest/process/clang-format.html) - [ ] [djhtml](https://github.com/rtts/djhtml) +- [ ] [dprint](https://dprint.dev/) - [ ] [fish_indent](https://fishshell.com/docs/current/cmds/fish_indent.html) - [ ] [fnlfmt](https://git.sr.ht/~technomancy/fnlfmt) - [ ] [gofmt](https://pkg.go.dev/cmd/gofmt) diff --git a/lua/guard-collection/formatter.lua b/lua/guard-collection/formatter.lua index 9ec3400..7d0baf6 100644 --- a/lua/guard-collection/formatter.lua +++ b/lua/guard-collection/formatter.lua @@ -35,6 +35,13 @@ M.djhtml = { stdin = true, } +M.dprint = { + cmd = "dprint", + args = { "fmt", "--stdin" }, + stdin = true, + fname = true, +} + M.fish_indent = { cmd = 'fish_indent', stdin = true, From e13d063d28f41a268c91e1c306b276a24673ace0 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 14 Sep 2023 22:12:58 +0200 Subject: [PATCH 2/4] Add dprint tests --- test/formatter/dprint_spec.lua | 18 ++++++++++++++++++ test/setup.sh | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/formatter/dprint_spec.lua diff --git a/test/formatter/dprint_spec.lua b/test/formatter/dprint_spec.lua new file mode 100644 index 0000000..b2477a5 --- /dev/null +++ b/test/formatter/dprint_spec.lua @@ -0,0 +1,18 @@ +describe('dprint', function() + it('can format', function() + local ft = require('guard.filetype') + ft('typescriptreact'):fmt('dprint') + require('guard').setup() + + local formatted = require('test.formatter.helper').test_with('typescriptreact', { + [[ const randomNumber = Math.floor(]], + [[ Math.random() * 10]], + [[ ) + 1]], + [[alert(randomNumber)]], + }) + assert.are.same({ + [[const randomNumber = Math.floor(Math.random() * 10) + 1;]], + [[alert(randomNumber);]], + }, formatted) + end) +end) diff --git a/test/setup.sh b/test/setup.sh index 8800339..67e5018 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -10,7 +10,8 @@ luarocks install luacheck & go install github.com/segmentio/golines@latest & pip -qqq install autopep8 black djhtml flake8 isort pylint yapf & npm install -g --silent \ - prettier @fsouza/prettierd sql-formatter shellcheck shfmt & + prettier @fsouza/prettierd sql-formatter shellcheck shfmt dprint & +dprint config add typescript & gem install -q rubocop & brew install \ swiftformat swift-format hadolint google-java-format pgformatter fnlfmt # Block, homebrew takes the longest time From c11ca9499a4b611f0651380a011cf84fe2ba355d Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 14 Sep 2023 22:25:01 +0200 Subject: [PATCH 3/4] Revert "Add dprint tests" This reverts commit 67bfbab4aad0921db7b3202146a4db16cf04f8a5. --- test/formatter/dprint_spec.lua | 18 ------------------ test/setup.sh | 3 +-- 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 test/formatter/dprint_spec.lua diff --git a/test/formatter/dprint_spec.lua b/test/formatter/dprint_spec.lua deleted file mode 100644 index b2477a5..0000000 --- a/test/formatter/dprint_spec.lua +++ /dev/null @@ -1,18 +0,0 @@ -describe('dprint', function() - it('can format', function() - local ft = require('guard.filetype') - ft('typescriptreact'):fmt('dprint') - require('guard').setup() - - local formatted = require('test.formatter.helper').test_with('typescriptreact', { - [[ const randomNumber = Math.floor(]], - [[ Math.random() * 10]], - [[ ) + 1]], - [[alert(randomNumber)]], - }) - assert.are.same({ - [[const randomNumber = Math.floor(Math.random() * 10) + 1;]], - [[alert(randomNumber);]], - }, formatted) - end) -end) diff --git a/test/setup.sh b/test/setup.sh index 67e5018..8800339 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -10,8 +10,7 @@ luarocks install luacheck & go install github.com/segmentio/golines@latest & pip -qqq install autopep8 black djhtml flake8 isort pylint yapf & npm install -g --silent \ - prettier @fsouza/prettierd sql-formatter shellcheck shfmt dprint & -dprint config add typescript & + prettier @fsouza/prettierd sql-formatter shellcheck shfmt & gem install -q rubocop & brew install \ swiftformat swift-format hadolint google-java-format pgformatter fnlfmt # Block, homebrew takes the longest time From e04529474bd5342f8e08c85a81c5c809989c5944 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 15 Sep 2023 20:59:28 +0200 Subject: [PATCH 4/4] Add find --- lua/guard-collection/formatter.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/guard-collection/formatter.lua b/lua/guard-collection/formatter.lua index 7d0baf6..b39a971 100644 --- a/lua/guard-collection/formatter.lua +++ b/lua/guard-collection/formatter.lua @@ -36,10 +36,11 @@ M.djhtml = { } M.dprint = { - cmd = "dprint", - args = { "fmt", "--stdin" }, + cmd = 'dprint', + args = { 'fmt', '--stdin' }, stdin = true, fname = true, + find = { 'dprint.json', 'dprint.jsonc', '.dprint.json', '.dprint.jsonc' }, } M.fish_indent = {