plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
17bcbee
— Peter John
2026-11-02T12:01:07+05:30
tooling: indent after an unfinished if/else/while/for/match/test or = header
plum-tooling/tree-sitter-plum/queries/plum/indents.scm
CHANGED
|
@@ -31,3 +31,17 @@
|
|
|
31
31
|
(break)
|
|
32
32
|
(continue)
|
|
33
33
|
] @extend.prevent-once
|
|
34
|
+
|
|
35
|
+
; While a block is being typed its opener has no body yet, so it parses as an
|
|
36
|
+
; ERROR node on its own line (`if x`, `else`, `else if x`, `while x`,
|
|
37
|
+
; `for i := range n`, `match x`, `test "a"`, or a header ending in `=` such as
|
|
38
|
+
; `fun f() =` / `struct Vec(x: Float) =`). Indent the line after it.
|
|
39
|
+
[
|
|
40
|
+
(ERROR "if")
|
|
41
|
+
(ERROR "else")
|
|
42
|
+
(ERROR "while")
|
|
43
|
+
(ERROR "for")
|
|
44
|
+
(ERROR "match")
|
|
45
|
+
(ERROR "test")
|
|
46
|
+
(ERROR "=")
|
|
47
|
+
] @indent
|
plum-tooling/vscode-plum/language-configuration.json
CHANGED
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
["`", "`"]
|
|
20
20
|
],
|
|
21
21
|
// symbols that can be used to surround a selection
|
|
22
|
+
// Indent after a block opener with no body yet: `if x` (not the inline
|
|
23
|
+
// `if a then b else c`), `else`, `while`, `for`, `match`, `test`, and any line
|
|
24
|
+
// ending in `=` (`fun f() =`, `struct Vec(x: Float) =`), `=>` or `catch e`.
|
|
25
|
+
// A typed `else` moves back out to its `if`.
|
|
26
|
+
"indentationRules": {
|
|
27
|
+
"increaseIndentPattern": "^\\s*(if\\b(?!.*\\bthen\\b)|else\\b(?!.*\\bthen\\b)|while\\b|for\\b|match\\b|test\\b).*$|^.*(=|=>|\\bcatch\\s+\\w+)\\s*(#.*)?$",
|
|
28
|
+
"decreaseIndentPattern": "^\\s*else\\b"
|
|
29
|
+
},
|
|
22
30
|
"surroundingPairs": [
|
|
23
31
|
["{", "}"],
|
|
24
32
|
["[", "]"],
|