Skip to content

Commit a55f21b

Browse files
authored
feat(formatter): add cmake-format formatter (#66)
1 parent 9e5b79a commit a55f21b

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
@@ -30,6 +30,12 @@ M.cbfmt = {
3030
stdin = true,
3131
}
3232

33+
M['cmake-format'] = {
34+
cmd = 'cmake-format',
35+
args = { '-' },
36+
stdin = true,
37+
}
38+
3339
M['clang-format'] = {
3440
cmd = 'clang-format',
3541
stdin = true,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
describe('cmake-format', function()
2+
it('can format', function()
3+
local ft = require('guard.filetype')
4+
ft('cmake'):fmt('cmake-format')
5+
6+
local formatted = require('test.formatter.helper').test_with('cmake', {
7+
[[cmake_minimum_required(VERSION 3.10)]],
8+
[[project(test)]],
9+
[[add_executable(test main.cpp)]],
10+
})
11+
assert.are.same({
12+
[[cmake_minimum_required(VERSION 3.10)]],
13+
[[project(test)]],
14+
[[add_executable(test main.cpp)]],
15+
}, formatted)
16+
end)
17+
end)

0 commit comments

Comments
 (0)