mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
feat(meson): add indents.scm
This commit is contained in:
parent
d198a75e2c
commit
6548bb64c1
10 changed files with 172 additions and 0 deletions
25
queries/meson/indents.scm
Normal file
25
queries/meson/indents.scm
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
[
|
||||
(list)
|
||||
(dictionaries)
|
||||
(normal_command)
|
||||
(if_condition)
|
||||
(foreach_command)
|
||||
(ternaryoperator)
|
||||
(ERROR
|
||||
"?") ; support partial ternary
|
||||
] @indent.begin
|
||||
|
||||
[
|
||||
")"
|
||||
"]"
|
||||
"}"
|
||||
(elseif_command)
|
||||
(else_command)
|
||||
"endif"
|
||||
"endforeach"
|
||||
] @indent.branch @indent.end
|
||||
|
||||
(experession_statement
|
||||
object: (_)) @indent.begin
|
||||
|
||||
(comment) @indent.auto
|
||||
16
tests/indent/meson/cond.meson
Normal file
16
tests/indent/meson/cond.meson
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# vim: ft=meson
|
||||
|
||||
if a == b
|
||||
endif
|
||||
|
||||
if a == b
|
||||
foo()
|
||||
endif
|
||||
|
||||
if a == b
|
||||
foo()
|
||||
elif a != b
|
||||
foo()
|
||||
else
|
||||
foo()
|
||||
endif
|
||||
15
tests/indent/meson/dict.meson
Normal file
15
tests/indent/meson/dict.meson
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# vim: ft=meson
|
||||
|
||||
foo = {
|
||||
'a': 1,
|
||||
'b': 2,
|
||||
}
|
||||
|
||||
bar = {
|
||||
'a': 1,
|
||||
'b': 2}
|
||||
|
||||
baz = {'a': 1,
|
||||
'b': 2
|
||||
}
|
||||
|
||||
13
tests/indent/meson/func.meson
Normal file
13
tests/indent/meson/func.meson
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# vim: ft=meson
|
||||
|
||||
executable('progname',
|
||||
)
|
||||
|
||||
executable('progname',
|
||||
sources: 'prog.c',
|
||||
c_args: '-DFOO=1'
|
||||
)
|
||||
|
||||
executable('progname',
|
||||
sources: 'prog.c',
|
||||
c_args: '-DFOO=1')
|
||||
14
tests/indent/meson/list.meson
Normal file
14
tests/indent/meson/list.meson
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# vim: ft=meson
|
||||
|
||||
foo = [
|
||||
'a',
|
||||
'b',
|
||||
]
|
||||
|
||||
bar = [
|
||||
'a',
|
||||
'b']
|
||||
|
||||
baz = ['a',
|
||||
'b'
|
||||
]
|
||||
8
tests/indent/meson/loop.meson
Normal file
8
tests/indent/meson/loop.meson
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# vim: ft=meson
|
||||
|
||||
foreach elem : list
|
||||
endforeach
|
||||
|
||||
foreach elem : list
|
||||
foo()
|
||||
endforeach
|
||||
34
tests/indent/meson/meson.build
Normal file
34
tests/indent/meson/meson.build
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
project('simple', 'c')
|
||||
|
||||
src = [
|
||||
'source1.c',
|
||||
'source2.c',
|
||||
]
|
||||
|
||||
if 1 == 2
|
||||
if meson.is_cross_build()
|
||||
src += [
|
||||
'src1.c',
|
||||
'src2.c']
|
||||
endif
|
||||
endif
|
||||
|
||||
inc = include_directories([
|
||||
'dir1/',
|
||||
])
|
||||
|
||||
|
||||
dep = declare_dependency(
|
||||
sources : src,
|
||||
include_directories : inc,
|
||||
)
|
||||
|
||||
executable('myexe', src,
|
||||
include_directories : [
|
||||
'd1',
|
||||
[
|
||||
'd2',
|
||||
'd3',
|
||||
]
|
||||
],
|
||||
dependencies: dep)
|
||||
8
tests/indent/meson/method.meson
Normal file
8
tests/indent/meson/method.meson
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# vim: ft=meson
|
||||
|
||||
myobj
|
||||
.do_something('now')
|
||||
|
||||
myobj.do_something('now')
|
||||
.do_something('now')
|
||||
.do_something('now')
|
||||
11
tests/indent/meson/ternary.meson
Normal file
11
tests/indent/meson/ternary.meson
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# vim: ft=meson
|
||||
|
||||
x = cond ?
|
||||
iftrue :
|
||||
iffalse
|
||||
|
||||
x = cond
|
||||
? iftrue
|
||||
: iffalse
|
||||
|
||||
x = cond ?
|
||||
28
tests/indent/meson_spec.lua
Normal file
28
tests/indent/meson_spec.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
local Runner = require("tests.indent.common").Runner
|
||||
|
||||
local run = Runner:new(it, "tests/indent/meson", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent Meson:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("cond.meson", { on_line = 3, text = "foo()", indent = 2 })
|
||||
run:new_line("cond.meson", { on_line = 6, text = "foo()", indent = 2 })
|
||||
run:new_line("cond.meson", { on_line = 7, text = "foo()", indent = 2 })
|
||||
run:new_line("cond.meson", { on_line = 12, text = "foo()", indent = 2 })
|
||||
run:new_line("cond.meson", { on_line = 14, text = "foo()", indent = 2 })
|
||||
run:new_line("dict.meson", { on_line = 13, text = ",'x':1,", indent = 2 })
|
||||
run:new_line("loop.meson", { on_line = 3, text = "foo()", indent = 2 })
|
||||
run:new_line("loop.meson", { on_line = 7, text = "foo()", indent = 2 })
|
||||
run:new_line("ternary.meson", { on_line = 11, text = "x : y", indent = 2 })
|
||||
end)
|
||||
end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue