Skip to content

Commit

Permalink
feat: swiftformat.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmurray8 committed Oct 4, 2024
1 parent fe25ff0 commit 60b3dbf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
- [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)
- [x] [swiftformat](https://github.com/nicklockwood/SwiftFormat)
- [ ] [swift-format](https://github.com/apple/swift-format)
- [ ] [sqlfluff](https://github.com/sqlfluff/sqlfluff) as `sqlfluff format`
- [x] [sqlfluff_fix](https://github.com/sqlfluff/sqlfluff) as `sqlfluff fix`
Expand Down
2 changes: 2 additions & 0 deletions lua/guard-collection/formatter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ M.stylua = {

M.swiftformat = {
cmd = 'swiftformat',
args = { '--stdinpath' },
stdin = true,
fname = true,
}

M['swift-format'] = {
Expand Down
18 changes: 18 additions & 0 deletions test/formatter/swiftformat.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe('swiftformat', function()
it('can format', function()
local ft = require('guard.filetype')
ft('swift'):fmt('swiftformat')
require('guard').setup()

local formatted = require('test.formatter.helper').test_with('swift', {
[[func myFunc() { ]],
[[print("hello") ]],
[[ }]],
})
assert.are.same({
[[func myFunc() {]],
[[ print("hello")]],
[[}]],
}, formatted)
end)
end)
2 changes: 1 addition & 1 deletion test/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pip -qqq install autopep8 black djhtml docformatter flake8 isort pylint yapf cod
npm install -g --silent \
prettier @fsouza/prettierd sql-formatter shellcheck shfmt @taplo/cli @biomejs/biome &
brew install \
hlint ormolu clang-format golines gofumpt detekt &
hlint ormolu clang-format golines gofumpt detekt swiftformat &

# Install standalone binary packages
bin="$HOME/.local/bin"
Expand Down

0 comments on commit 60b3dbf

Please sign in to comment.