This commit is contained in:
2025-09-21 22:54:00 +02:00
parent 95624267db
commit 9482b629c1
2 changed files with 64 additions and 10 deletions

View File

@@ -20,6 +20,13 @@
value: (_) @prepend_indent_start @append_indent_end @prepend_begin_measuring_scope @append_end_measuring_scope value: (_) @prepend_indent_start @append_indent_end @prepend_begin_measuring_scope @append_end_measuring_scope
body: (_) @prepend_hardline body: (_) @prepend_hardline
(#scope_id! "def")) (#scope_id! "def"))
; ; remove `in`
; (let_binding
; "in" @delete)
; add `in`
(let_binding
value: (_) @append_delimiter @append_space
(#delimiter! " in"))
(def (def
":" @prepend_space @append_spaced_softline ":" @prepend_space @append_spaced_softline
@@ -105,16 +112,22 @@
(function_call (function_call
"," @append_spaced_softline) "," @append_spaced_softline)
; ==== SIMILAR TO record_type ====
(record_expr_field (record_expr_field
":" @append_spaced_softline) ":" @append_spaced_softline)
(record_expr (record_expr
"," @append_spaced_softline) "," @append_spaced_softline)
(record_expr (record_expr
"{" @append_empty_softline "{" @append_empty_softline @append_begin_measuring_scope @append_indent_start
"}" @prepend_empty_softline) "}" @prepend_empty_softline ; TODO: make this one configurable; also see lists and others
@append_end_measuring_scope @prepend_indent_end
(#scope_id! "record_expr"))
; remove trailing comma ; remove trailing comma
(record_expr (record_expr
"," @delete . "}") "," @delete . "}")
; ====^^^^^^^^^^^^========
(atom (atom
"(" @append_begin_measuring_scope @append_empty_softline @append_indent_start "(" @append_begin_measuring_scope @append_empty_softline @append_indent_start
@@ -133,12 +146,6 @@
"->" @prepend_space @append_spaced_softline "->" @prepend_space @append_spaced_softline
body: (_) @prepend_indent_start @append_indent_end) body: (_) @prepend_indent_start @append_indent_end)
(type_atom
"(" @append_begin_measuring_scope @append_empty_softline @append_indent_start
")" @append_end_measuring_scope @prepend_empty_softline @append_indent_end
(#scope_id! "paren_type"))
(tag_expr (tag_expr
tag: (_) @append_space) tag: (_) @append_space)
@@ -146,7 +153,54 @@
left: (_) @append_spaced_softline left: (_) @append_spaced_softline
right: (_) @prepend_space) right: (_) @prepend_space)
; TODO: types
(type_atom
"(" @append_begin_measuring_scope @append_empty_softline @append_indent_start
")" @append_end_measuring_scope @prepend_empty_softline @append_indent_end
(#scope_id! "paren_type"))
(fn_type
"->" @prepend_space @append_spaced_softline)
; ==== SIMILAR TO record_expr ====
(record_type_field
":" @append_spaced_softline)
(record_type
"," @append_spaced_softline)
(record_type
"{" @append_empty_softline @append_begin_measuring_scope @append_indent_start
"}" @prepend_empty_softline ; TODO: make this one configurable; also see lists and others
@append_end_measuring_scope @prepend_indent_end
(#scope_id! "record_type"))
; remove trailing comma
(record_type
"," @delete . "}")
; ====^^^^^^^^^^^^========
; 'Tag Unit -> 'Tag
(tagged_type
type: (type_atom (just_type (path
(identifier) @delete
(#eq? @delete "Unit")))))
(tagged_type
type: (_) @prepend_space)
(type_atom
"(" @delete
. (type (type_atom))
. ")" @delete)
; TODO:
; $.union_type,
; $.partial_union_type,
; $.parametrized_type,
; $.with_type,
; $.recursive_type,
; TODO: disable-format-regions ; TODO: disable-format-regions
; TODO: folding query ; TODO: folding query
; TODO: wrap confusing expressions (in terms of precedence) in parens ; TODO: wrap confusing expressions (in terms of precedence) in parens