Skip to content

Commit

Permalink
queries/templ: add indents
Browse files Browse the repository at this point in the history
  • Loading branch information
vrischmann committed Jan 22, 2024
1 parent a3ef3d8 commit 1f7f612
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions queries/templ/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
; inherits: go

; [
; (component_block)
; ] @indent.begin

; ((tag_start) @indent.begin
; (#set! indent.immediate 1))
;
; ((tag_end) @indent.end)

; (component_block
; "{" @indent.branch)


[
((element
(tag_start
(element_identifier) @_not_special))
(#not-any-of? @_not_special "meta" "link"))
(element
(self_closing_tag))
] @indent.begin

; These tags are usually written one-lined and doesn't use self-closing tags so special-cased them
; but add indent to the tag to make sure attributes inside them are still indented if written multi-lined
((tag_start
(element_identifier) @_special)
(#any-of? @_special "meta" "link")) @indent.begin

; These are the nodes that will be captured when we do `normal o`
; But last element has already been ended, so capturing this
; to mark end of last element
(element
(tag_end
">" @indent.end))

(element
(self_closing_tag
"/>" @indent.end))

; Script/style elements aren't indented, so only branch the end tag of other elements
(element
(tag_end) @indent.branch)

[
">"
"/>"
] @indent.branch

0 comments on commit 1f7f612

Please sign in to comment.