fix(format): handle list with 300 nodes

This commit is contained in:
Phạm Huy Hoàng 2024-01-30 22:19:54 +07:00
parent e9602f4119
commit 5f950cdcb8
5 changed files with 7 additions and 23 deletions

View file

@ -277,9 +277,9 @@
)) ))
; Builtin Funcs ; Builtin Funcs
; format-ignore
(call (call
(identifier) @function.builtin (identifier) @function.builtin
; format-ignore
(#any-of? @function.builtin (#any-of? @function.builtin
; @GlobalScope ; @GlobalScope
"abs" "absf" "absi" "acos" "asin" "atan" "atan2" "bezier_derivative" "abs" "absf" "absi" "acos" "asin" "atan" "atan2" "bezier_derivative"

View file

@ -165,8 +165,7 @@
"background" "background"
"rounded" "rounded"
"butt" "butt"
]* ]* @attribute)
@attribute)
; (t_canvas) ; (t_canvas)
; (t_cgm) ; (t_cgm)
@ -288,7 +287,6 @@
] @variable.member ] @variable.member
; Workaround because formatter cannot handle 300 list nodes ; Workaround because formatter cannot handle 300 list nodes
; format-ignore
[ [
(angles) (angles)
(clip) (clip)

View file

@ -74,8 +74,7 @@
; ":::=" ; ":::="
"?=" "?="
"!=" "!="
]? ]? @operator
@operator
"endef" @keyword) "endef" @keyword)
(variable_assignment (variable_assignment

View file

@ -116,8 +116,7 @@
[ [
"end" "end"
"endfunction" "endfunction"
]? ]? @keyword.function)
@keyword.function)
(function_signature (function_signature
name: (identifier) @function) name: (identifier) @function)

View file

@ -106,25 +106,19 @@ local format_queries = [[
;; Only starts indent if 2 or more elements ;; Only starts indent if 2 or more elements
(list (list
"[" @format.indent.begin "[" @format.indent.begin
.
(_)
.
(_)
"]" @format.indent.dedent) "]" @format.indent.dedent)
;; Otherwise, remove brackets ;; Otherwise, remove brackets
(list (list
"[" @format.remove "[" @format.remove @format.cancel-append
. .
(_) @format.cancel-append (_) @format.cancel-append
. .
"]" @format.remove) "]" @format.remove)
;; [ ... ] @capture1 @capture2 ;; [ ... ] @capture1 @capture2
(list
(capture) @format.prepend-space)
;; Append newlines for nodes inside the list ;; Append newlines for nodes inside the list
(list (list
(_) @format.append-newline (_) @format.append-newline
(#not-has-type? @format.append-newline capture)) (#not-has-type? @format.append-newline capture quantifier))
;; (_), "_" and _ handler ;; (_), "_" and _ handler
;; Start indents if it's one of these patterns ;; Start indents if it's one of these patterns
@ -176,9 +170,6 @@ local format_queries = [[
(anonymous_node) (anonymous_node)
"." "."
] @format.append-newline) ] @format.append-newline)
(named_node
(list
"[" . (_) @format.append-newline . "]"))
;; Collapse closing parentheses ;; Collapse closing parentheses
(named_node (named_node
@ -192,10 +183,7 @@ local format_queries = [[
(#not-has-type? @format.cancel-append comment)) (#not-has-type? @format.cancel-append comment))
;; All captures should be separated with a space ;; All captures should be separated with a space
(named_node (capture) @format.prepend-space
(capture) @format.prepend-space)
(anonymous_node
(capture) @format.prepend-space)
;; Workaround to just use the string's content ;; Workaround to just use the string's content
(anonymous_node (identifier) @format.keep) (anonymous_node (identifier) @format.keep)