mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 02:10:15 -04:00
indents(wgsl): add indents.scm
This commit is contained in:
parent
aa736f5f36
commit
27cba73df9
3 changed files with 81 additions and 0 deletions
19
queries/wgsl/indents.scm
Normal file
19
queries/wgsl/indents.scm
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[
|
||||||
|
(parameter_list)
|
||||||
|
(compound_statement)
|
||||||
|
(loop_statement)
|
||||||
|
(struct_declaration)
|
||||||
|
] @indent
|
||||||
|
|
||||||
|
(compound_statement "}" @indent_end)
|
||||||
|
(loop_statement "}" @indent_end)
|
||||||
|
(function_declaration ")" @indent_end)
|
||||||
|
(struct_declaration "}" @indent_end)
|
||||||
|
|
||||||
|
[
|
||||||
|
"else"
|
||||||
|
")"
|
||||||
|
"}"
|
||||||
|
] @branch
|
||||||
|
|
||||||
|
(comment) @auto
|
||||||
43
tests/indent/wgsl/basic.wgsl
Normal file
43
tests/indent/wgsl/basic.wgsl
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
struct Vertex {
|
||||||
|
@location(0) position: vec3<f32>,
|
||||||
|
@location(1) color: vec4<f32>,
|
||||||
|
};
|
||||||
|
|
||||||
|
@vertex
|
||||||
|
fn vertex(vertex: Vertex) -> VertexOutput {
|
||||||
|
var out: VertexOutput;
|
||||||
|
out.a = 1;
|
||||||
|
if (1) {
|
||||||
|
out.a = 3;
|
||||||
|
}
|
||||||
|
if (2) {
|
||||||
|
dsa;
|
||||||
|
}
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if (i >= 4) { break; }
|
||||||
|
}
|
||||||
|
out.b = 2;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@vertex
|
||||||
|
fn vertex(vertex: Vertex,
|
||||||
|
foo: dso,
|
||||||
|
foo: dsa
|
||||||
|
) -> VertexOutput {
|
||||||
|
var out: VertexOutput;
|
||||||
|
out.a = 1;
|
||||||
|
out.b = 2;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@vertex
|
||||||
|
fn vertex(vertex: Vertex,
|
||||||
|
foo: dso,
|
||||||
|
foo: dsa) -> VertexOutput {
|
||||||
|
var out: VertexOutput;
|
||||||
|
out.a = 1;
|
||||||
|
out.b = 2;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
19
tests/indent/wgsl_spec.lua
Normal file
19
tests/indent/wgsl_spec.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
local Runner = require("tests.indent.common").Runner
|
||||||
|
--local XFAIL = require("tests.indent.common").XFAIL
|
||||||
|
|
||||||
|
local run = Runner:new(it, "tests/indent/wgsl", {
|
||||||
|
tabstop = 4,
|
||||||
|
shiftwidth = 4,
|
||||||
|
softtabstop = 0,
|
||||||
|
expandtab = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("indent WGSL:", function()
|
||||||
|
describe("whole file:", function()
|
||||||
|
run:whole_file(".", {
|
||||||
|
expected_failures = {},
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe("new line:", function() end)
|
||||||
|
end)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue