mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-14 01:10:02 -04:00
feat(dot): add indents queries
* feat(dot): add indents queries * add: tests * fix: test
This commit is contained in:
parent
3ae78f376c
commit
904f373fc4
3 changed files with 42 additions and 0 deletions
9
queries/dot/indents.scm
Normal file
9
queries/dot/indents.scm
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[
|
||||||
|
(block)
|
||||||
|
(attr_list)
|
||||||
|
] @indent.begin
|
||||||
|
|
||||||
|
[
|
||||||
|
"}"
|
||||||
|
"]"
|
||||||
|
] @indent.branch @indent.end
|
||||||
8
tests/indent/dot/test.dot
Normal file
8
tests/indent/dot/test.dot
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
digraph {
|
||||||
|
node [
|
||||||
|
shape=ellipse,
|
||||||
|
];
|
||||||
|
subgraph sub {
|
||||||
|
a1 -> a2 -> a3;
|
||||||
|
}
|
||||||
|
}
|
||||||
25
tests/indent/dot_spec.lua
Normal file
25
tests/indent/dot_spec.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
local Runner = require("tests.indent.common").Runner
|
||||||
|
|
||||||
|
local run = Runner:new(it, "tests/indent/dot", {
|
||||||
|
tabstop = 2,
|
||||||
|
shiftwidth = 2,
|
||||||
|
softtabstop = 0,
|
||||||
|
expandtab = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("indent dot:", function()
|
||||||
|
describe("whole file:", function()
|
||||||
|
run:whole_file(".", {
|
||||||
|
expected_failures = {},
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe("new line:", function()
|
||||||
|
run:new_line("test.dot", { on_line = 1, text = "node [", indent = 2 })
|
||||||
|
run:new_line("test.dot", { on_line = 2, text = "shape=ellipse,", indent = 4 })
|
||||||
|
run:new_line("test.dot", { on_line = 4, text = "subgraph sub {", indent = 2 })
|
||||||
|
run:new_line("test.dot", { on_line = 5, text = "a1 -> a2 -> a3;", indent = 4 })
|
||||||
|
run:new_line("test.dot", { on_line = 6, text = "}", indent = 2 })
|
||||||
|
run:new_line("test.dot", { on_line = 7, text = "}", indent = 0 })
|
||||||
|
end)
|
||||||
|
end)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue