feat(dot): add indents queries

* feat(dot): add indents queries

* add: tests

* fix: test
This commit is contained in:
Luckas 2024-03-15 03:18:33 +03:00 committed by GitHub
parent 3ae78f376c
commit 904f373fc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 0 deletions

9
queries/dot/indents.scm Normal file
View file

@ -0,0 +1,9 @@
[
(block)
(attr_list)
] @indent.begin
[
"}"
"]"
] @indent.branch @indent.end

View file

@ -0,0 +1,8 @@
digraph {
node [
shape=ellipse,
];
subgraph sub {
a1 -> a2 -> a3;
}
}

25
tests/indent/dot_spec.lua Normal file
View 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)