1 Commits

Author SHA1 Message Date
91434933a6 a 2025-09-21 22:29:15 +02:00
2 changed files with 18 additions and 65 deletions

View File

@@ -115,7 +115,7 @@ module.exports = grammar({
type_atom: $ => choice(
$.just_type,
$.partial_type,
$.partial_type,
seq('(', $.type, ')'),
$.record_type,
),

View File

@@ -19,14 +19,14 @@
"=" @prepend_space @append_space
value: (_) @prepend_indent_start @append_indent_end @prepend_begin_measuring_scope @append_end_measuring_scope
body: (_) @prepend_hardline
(#scope_id! "def"))
; ; remove `in`
; (let_binding
; "in" @delete)
; add `in`
(let_binding
value: (_) @append_delimiter @append_space
(#delimiter! " in"))
(#scope_id! "let"))
(await_binding
"await" @prepend_spaced_softline @append_space
"=" @prepend_space @append_space
value: (_) @prepend_indent_start @append_indent_end @prepend_begin_measuring_scope @append_end_measuring_scope
body: (_) @prepend_hardline
(#scope_id! "await"))
(def
":" @prepend_space @append_spaced_softline
@@ -112,22 +112,16 @@
(function_call
"," @append_spaced_softline)
; ==== SIMILAR TO record_type ====
(record_expr_field
":" @append_spaced_softline)
(record_expr
"," @append_spaced_softline)
(record_expr
"{" @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_expr"))
"{" @append_empty_softline
"}" @prepend_empty_softline)
; remove trailing comma
(record_expr
"," @delete . "}")
; ====^^^^^^^^^^^^========
(atom
"(" @append_begin_measuring_scope @append_empty_softline @append_indent_start
@@ -146,6 +140,12 @@
"->" @prepend_space @append_spaced_softline
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: (_) @append_space)
@@ -153,54 +153,7 @@
left: (_) @append_spaced_softline
right: (_) @prepend_space)
(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: types
; TODO: disable-format-regions
; TODO: folding query
; TODO: wrap confusing expressions (in terms of precedence) in parens