aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhạm Huy Hoàng <hoangtun0810@gmail.com>2024-01-21 21:13:04 +0900
committerPhạm Huy Hoàng <hoangtun0810@gmail.com>2024-01-21 23:55:02 +0900
commit76ca66db38edb07bade5b7b233254b2c2ae7dc30 (patch)
tree29853577f8932b37342e28baed884f8bca2e1975
parentfix(jsdoc): add nospell to type and tag_name (diff)
downloadnvim-treesitter-76ca66db38edb07bade5b7b233254b2c2ae7dc30.tar
nvim-treesitter-76ca66db38edb07bade5b7b233254b2c2ae7dc30.tar.gz
nvim-treesitter-76ca66db38edb07bade5b7b233254b2c2ae7dc30.tar.bz2
nvim-treesitter-76ca66db38edb07bade5b7b233254b2c2ae7dc30.tar.lz
nvim-treesitter-76ca66db38edb07bade5b7b233254b2c2ae7dc30.tar.xz
nvim-treesitter-76ca66db38edb07bade5b7b233254b2c2ae7dc30.tar.zst
nvim-treesitter-76ca66db38edb07bade5b7b233254b2c2ae7dc30.zip
fix(format-scripts): remove parens if possible
-rwxr-xr-xscripts/format-queries.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/scripts/format-queries.lua b/scripts/format-queries.lua
index d42d5b255..67b850976 100755
--- a/scripts/format-queries.lua
+++ b/scripts/format-queries.lua
@@ -204,7 +204,9 @@ local format_queries = [[
[
(named_node [ (named_node) (list) (grouping) (anonymous_node) (field_definition) ])
(list "[" . (_) . (_) "]")
- (grouping)
+ (grouping "(" . (_) . (_) ")")
+ (grouping
+ quantifier: (quantifier))
])
; ( (_) ) handler
@@ -240,6 +242,29 @@ local format_queries = [[
(#not-has-type? @format.cancel-append comment))
(grouping
(capture) @format.prepend-space)
+;; Remove unnecessary parens
+(grouping
+ "(" @format.remove
+ .
+ (_)
+ .
+ ")" @format.remove .)
+(grouping
+ "(" @format.remove
+ .
+ [
+ (anonymous_node
+ name: (identifier) .)
+ (named_node
+ [
+ "_"
+ name: (identifier)
+ ] .)
+ ]
+ .
+ ")" @format.remove
+ .
+ (capture))
(predicate
(parameters