Skip to content

Commit

Permalink
Remove dead rule, fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yannham committed Sep 19, 2024
1 parent 6c793cf commit dbc5dce
Showing 1 changed file with 5 additions and 44 deletions.
49 changes: 5 additions & 44 deletions topiary-queries/queries/nickel.scm
Original file line number Diff line number Diff line change
Expand Up @@ -333,42 +333,6 @@
(_) @append_begin_scope
.
(annot) @append_end_scope
.
)

; We want to include a potential "=" following the annotation in the scope, so
; that we can properly add a newline between the last annotation and the "=" in
; multi-line mode:
;
; {
; foo
; | Number
; | doc "hello"
; = 5,
; }
;
; if we didn't include this rule, we could have
;
; | doc "hello" = 5,
;
; which is arguably confusing
;
; Note that this query is disjoint from the other one defining the "annotations"
; scope above, which that only applies when the annotation is the last named
; node of its parent. Thus, only one of the two ever matches.
;
; WARNING: currently, splitting the rule in two is useless because we actually
; add the newline before `=` inconditionally (see
; [^annotations-followed-by-eq]). However, when this limitation is lifted, the
; current rule architecture will allow for the desired formatting with minimal
; change.
(
(#scope_id! "annotations")
(_) @append_begin_scope
.
(annot)
.
"=" @append_end_scope
)

; Put each annotation on a new line, in a multi-line context.
Expand Down Expand Up @@ -419,27 +383,24 @@
;
; which isn't optimal but still acceptable.
(
(#scope_id! "annotations")
(annot) @append_spaced_scoped_softline
(annot) @append_spaced_softline
.
"="
)

; Indent the annotations themselves in multi-line mode with respect to the
; identifier they annotate.
; Indent the annotations with respect to the identifier they annotate.
(
(#multi_line_scope_only! "annotations")
(annot_atom) @prepend_indent_start @append_indent_end
(annot) @prepend_indent_start @append_indent_end
)

; Indent the RHS of the let-binding in presence of annotations.
;
; Ideally, we would like to indent only when annotations are multi-line, but
; this isn't current possible; see [^annotations-followed-by-eq].
(_
(annot) @append_indent_start
(annot)
.
"="
"=" @prepend_indent_start
.
(_) @append_indent_end
)
Expand Down

0 comments on commit dbc5dce

Please sign in to comment.