diff --git a/runtime/queries/typst/indents.scm b/runtime/queries/typst/indents.scm index d43c586c..424320fe 100644 --- a/runtime/queries/typst/indents.scm +++ b/runtime/queries/typst/indents.scm @@ -3,10 +3,12 @@ (let) (show) (call) + (for) + (branch) ] @indent.begin [ "]" "}" ")" -] @indent.branch @indent.end +] @indent.end @indent.branch diff --git a/tests/indent/typst/call.typ b/tests/indent/typst/call.typ new file mode 100644 index 00000000..f0a64c97 --- /dev/null +++ b/tests/indent/typst/call.typ @@ -0,0 +1,14 @@ +#foo( + arg1, + arg2, +) + +#bar[ + content here +] + +#baz( + inner( + nested, + ), +) diff --git a/tests/indent/typst/for.typ b/tests/indent/typst/for.typ new file mode 100644 index 00000000..95fe60e9 --- /dev/null +++ b/tests/indent/typst/for.typ @@ -0,0 +1,8 @@ +#for x in (1, 2, 3) { + x +} + +#for x in (1, 2, 3) { + let y = x + 1 + y +} diff --git a/tests/indent/typst/if.typ b/tests/indent/typst/if.typ new file mode 100644 index 00000000..41bbaa4c --- /dev/null +++ b/tests/indent/typst/if.typ @@ -0,0 +1,15 @@ +#if true { + "this is one leve" +} + +#set page(header: { + if true { + "this is internal on level" + } +}) + +#if true { + if false { + "this is it" + } +} diff --git a/tests/indent/typst/let.typ b/tests/indent/typst/let.typ new file mode 100644 index 00000000..fa0c374c --- /dev/null +++ b/tests/indent/typst/let.typ @@ -0,0 +1,13 @@ +#let foo( + x, + y, +) = x + y + +#let bar = { + let x = 1 + x +} + +#let baz(x) = { + x + 1 +} diff --git a/tests/indent/typst/set.typ b/tests/indent/typst/set.typ new file mode 100644 index 00000000..861b2f95 --- /dev/null +++ b/tests/indent/typst/set.typ @@ -0,0 +1,9 @@ +#set text( + size: 12pt, + font: "Arial", +) + +#set page( + width: 210mm, + height: 297mm, +) diff --git a/tests/indent/typst/show.typ b/tests/indent/typst/show.typ new file mode 100644 index 00000000..3947b66c --- /dev/null +++ b/tests/indent/typst/show.typ @@ -0,0 +1,7 @@ +#show heading: it => { + it +} + +#show link: it => { + underline(it) +} diff --git a/tests/indent/typst_spec.lua b/tests/indent/typst_spec.lua new file mode 100644 index 00000000..81540405 --- /dev/null +++ b/tests/indent/typst_spec.lua @@ -0,0 +1,12 @@ +local Runner = require('tests.indent.common').Runner + +local run = Runner:new(it, 'tests/indent/typst', { + tabstop = 4, + shiftwidth = 4, + softtabstop = 4, + expandtab = false, +}) + +describe('indent typst:', function() + run:whole_file('.') +end)