Skip to content

Commit 9e5b79a

Browse files
authored
feat(formatter): add buf protobuf formatter (#65)
1 parent 4b6803b commit 9e5b79a

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

lua/guard-collection/formatter.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,12 @@ M.biome = {
311311
stdin = true,
312312
}
313313

314+
M.buf = {
315+
cmd = 'buf',
316+
args = { 'format' },
317+
stdin = true,
318+
}
319+
314320
M.xmllint = {
315321
cmd = 'xmllint',
316322
args = { '--format', '-' },

test/formatter/buf_spec.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
describe('buf', function()
2+
it('can format', function()
3+
local ft = require('guard.filetype')
4+
ft('proto'):fmt('buf')
5+
6+
local formatted = require('test.formatter.helper').test_with('proto', {
7+
[[syntax = "proto3"; message Foo { string bar = 1; }]],
8+
})
9+
assert.are.same({
10+
[[syntax = "proto3";]],
11+
[[]],
12+
[[message Foo {]],
13+
[[ string bar = 1;]],
14+
[[}]],
15+
}, formatted)
16+
end)
17+
end)

0 commit comments

Comments
 (0)