Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add biome as formatter #45

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `lsp` using `vim.lsp.buf.format`
- [x] [autopep8](https://github.com/hhatto/autopep8)
- [x] [black](https://github.com/psf/black)
- [x] [biome](https://biomejs.dev)
- [ ] [cbfmt](https://github.com/lukas-reineke/cbfmt)
- [x] [clang-format](https://www.kernel.org/doc/html/latest/process/clang-format.html)
- [ ] [csharpier](https://csharpier.com/)
Expand Down
7 changes: 7 additions & 0 deletions lua/guard-collection/formatter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,11 @@ M.zigfmt = {
stdin = true,
}

M.biome = {
cmd = 'biome',
args = { 'format', '--write' },
fname = true,
stdin = false,
}

return M
32 changes: 32 additions & 0 deletions test/formatter/biome_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
describe('biome', function()
it('can format json', function()
local ft = require('guard.filetype')
ft('json'):fmt('biome')
require('guard').setup()

local formatted = require('test.formatter.helper').test_with('json', {
[[{"name": "dove" , "age":10 ]],
[[,"gender": "male"}]],
})
assert.are.same({
[[{ "name": "dove", "age": 10, "gender": "male" }]],
}, formatted)
end)

it('can format javascript', function()
local ft = require('guard.filetype')
ft('js'):fmt('biome')
require('guard').setup()

local formatted = require('test.formatter.helper').test_with('js', {
[[ 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)
2 changes: 1 addition & 1 deletion test/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
luarocks install luacheck &
pip -qqq install autopep8 black djhtml docformatter flake8 isort pylint yapf codespell ruff sqlfluff clang-tidy mypy &
npm install -g --silent \
prettier @fsouza/prettierd sql-formatter shellcheck shfmt @taplo/cli &
prettier @fsouza/prettierd sql-formatter shellcheck shfmt @taplo/cli @biomejs/biome &
brew install \
hlint ormolu clang-format golines gofumpt detekt &

Expand Down
Loading