plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


b29055cPeter John 2026-07-19T17:24:33+05:30
feat: add Topiary format.scm formatting rules for Plum
tooling/tree-sitter-plum/queries/plum/format.scm ADDED
@@ -0,0 +1,90 @@
1
+ ; ============================================================
2
+ ; Top-level items — blank line between each
3
+ ; ============================================================
4
+
5
+ (source
6
+ (fn) @allow_blank_line_before)
7
+
8
+ (source
9
+ (class) @allow_blank_line_before)
10
+
11
+ (source
12
+ (enum) @allow_blank_line_before)
13
+
14
+ (source
15
+ (trait) @allow_blank_line_before)
16
+
17
+ (source
18
+ (const) @allow_blank_line_before)
19
+
20
+ ; ============================================================
21
+ ; Binary operators — space before and after
22
+ ; ============================================================
23
+
24
+ [
25
+ "+"
26
+ "-"
27
+ "*"
28
+ "/"
29
+ "%"
30
+ "^"
31
+ "|"
32
+ "&"
33
+ "<<"
34
+ ">>"
35
+ ".."
36
+ ] @prepend_space @append_space
37
+
38
+ [
39
+ "=="
40
+ "!="
41
+ "<"
42
+ "<="
43
+ ">"
44
+ ">="
45
+ "<>"
46
+ "&&"
47
+ "||"
48
+ ] @prepend_space @append_space
49
+
50
+ ; ============================================================
51
+ ; Assignment and arrows
52
+ ; ============================================================
53
+
54
+ "=" @prepend_space @append_space
55
+
56
+ "->" @prepend_space @append_space
57
+
58
+ "=>" @prepend_space @append_space
59
+
60
+ ; ============================================================
61
+ ; Separators — no space before, one space after
62
+ ; ============================================================
63
+
64
+ "," @append_space
65
+
66
+ ":" @append_space
67
+
68
+ ; ============================================================
69
+ ; Enum variant separators — new line before each |
70
+ ; ============================================================
71
+
72
+ (enum_variant
73
+ "|" @prepend_hardline)
74
+
75
+ ; ============================================================
76
+ ; Function body — each statement on its own line
77
+ ; ============================================================
78
+
79
+ (body
80
+ (_) @prepend_hardline)
81
+
82
+ ; ============================================================
83
+ ; Indent / dedent tokens — strip them (Topiary regenerates indentation)
84
+ ; ============================================================
85
+
86
+ (indent) @delete
87
+
88
+ (dedent) @delete
89
+
90
+ (newline) @delete