aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/format-queries.lua
diff options
context:
space:
mode:
authorPhạm Huy Hoàng <hoangtun0810@gmail.com>2024-01-30 22:19:54 +0700
committerPhạm Huy Hoàng <hoangtun0810@gmail.com>2024-01-30 22:59:27 +0700
commit5f950cdcb82d2cf74e6b30338897b3a4897f52b3 (patch)
tree32f116d4c7f1b32df70c70b896f7ac0fc164eda9 /scripts/format-queries.lua
parentfix(format): improve error message (diff)
downloadnvim-treesitter-5f950cdcb82d2cf74e6b30338897b3a4897f52b3.tar
nvim-treesitter-5f950cdcb82d2cf74e6b30338897b3a4897f52b3.tar.gz
nvim-treesitter-5f950cdcb82d2cf74e6b30338897b3a4897f52b3.tar.bz2
nvim-treesitter-5f950cdcb82d2cf74e6b30338897b3a4897f52b3.tar.lz
nvim-treesitter-5f950cdcb82d2cf74e6b30338897b3a4897f52b3.tar.xz
nvim-treesitter-5f950cdcb82d2cf74e6b30338897b3a4897f52b3.tar.zst
nvim-treesitter-5f950cdcb82d2cf74e6b30338897b3a4897f52b3.zip
fix(format): handle list with 300 nodes
Diffstat (limited to 'scripts/format-queries.lua')
-rwxr-xr-xscripts/format-queries.lua18
1 files changed, 3 insertions, 15 deletions
diff --git a/scripts/format-queries.lua b/scripts/format-queries.lua
index b7c230096..5cb0fb1a2 100755
--- a/scripts/format-queries.lua
+++ b/scripts/format-queries.lua
@@ -106,25 +106,19 @@ local format_queries = [[
;; Only starts indent if 2 or more elements
(list
"[" @format.indent.begin
- .
- (_)
- .
- (_)
"]" @format.indent.dedent)
;; Otherwise, remove brackets
(list
- "[" @format.remove
+ "[" @format.remove @format.cancel-append
.
(_) @format.cancel-append
.
"]" @format.remove)
;; [ ... ] @capture1 @capture2
-(list
- (capture) @format.prepend-space)
;; Append newlines for nodes inside the list
(list
(_) @format.append-newline
- (#not-has-type? @format.append-newline capture))
+ (#not-has-type? @format.append-newline capture quantifier))
;; (_), "_" and _ handler
;; Start indents if it's one of these patterns
@@ -176,9 +170,6 @@ local format_queries = [[
(anonymous_node)
"."
] @format.append-newline)
-(named_node
- (list
- "[" . (_) @format.append-newline . "]"))
;; Collapse closing parentheses
(named_node
@@ -192,10 +183,7 @@ local format_queries = [[
(#not-has-type? @format.cancel-append comment))
;; All captures should be separated with a space
-(named_node
- (capture) @format.prepend-space)
-(anonymous_node
- (capture) @format.prepend-space)
+(capture) @format.prepend-space
;; Workaround to just use the string's content
(anonymous_node (identifier) @format.keep)