plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
b548244
— Peter John
2026-09-04T21:34:47+05:30
fix(format): preserve blank lines in class/enum bodies, closure body spacing
tooling/tree-sitter-plum/queries/plum/format.scm
CHANGED
|
@@ -171,6 +171,15 @@
|
|
|
171
171
|
(class
|
|
172
172
|
(fn) @prepend_hardline)
|
|
173
173
|
|
|
174
|
+
; A blank line between two fields/methods (or a field and a method) inside a
|
|
175
|
+
; `type` body is preserved if the source already had one — same as top-level
|
|
176
|
+
; items — rather than always being collapsed to a single hardline.
|
|
177
|
+
(class
|
|
178
|
+
(field) @allow_blank_line_before)
|
|
179
|
+
|
|
180
|
+
(class
|
|
181
|
+
(fn) @allow_blank_line_before)
|
|
182
|
+
|
|
174
183
|
(class
|
|
175
184
|
"=" @append_indent_start)
|
|
176
185
|
|
|
@@ -194,6 +203,13 @@
|
|
|
194
203
|
(enum
|
|
195
204
|
(fn) @prepend_hardline)
|
|
196
205
|
|
|
206
|
+
; Same blank-line preservation as `class` above.
|
|
207
|
+
(enum
|
|
208
|
+
(field) @allow_blank_line_before)
|
|
209
|
+
|
|
210
|
+
(enum
|
|
211
|
+
(fn) @allow_blank_line_before)
|
|
212
|
+
|
|
197
213
|
(enum
|
|
198
214
|
"=" @append_indent_start)
|
|
199
215
|
|
|
@@ -228,6 +244,18 @@
|
|
|
228
244
|
(_) @append_indent_end
|
|
229
245
|
.)
|
|
230
246
|
|
|
247
|
+
; ============================================================
|
|
248
|
+
; Closures — a space between the closing "|" and an inline expression
|
|
249
|
+
; body (`|v| v + 1`), same as `assert`/`return`'s optional-expression
|
|
250
|
+
; rule above. Targeting the `body` FIELD (not a bare "|" token, which
|
|
251
|
+
; appears twice — once opening, once closing) picks out only the
|
|
252
|
+
; closing one, regardless of whether the body is a single expression
|
|
253
|
+
; or an indented block.
|
|
254
|
+
; ============================================================
|
|
255
|
+
|
|
256
|
+
(closure
|
|
257
|
+
body: (_) @prepend_space)
|
|
258
|
+
|
|
231
259
|
; ============================================================
|
|
232
260
|
; Function body — each statement on its own line
|
|
233
261
|
; ============================================================
|