feat(predicates)!: rename has-type to kind-eq to align with Helix

No point in having a different name for the same predicate.
This commit is contained in:
Christian Clason 2024-06-01 13:37:08 +02:00
parent deb76a224a
commit a80fe081b4
8 changed files with 16 additions and 16 deletions

View file

@ -124,7 +124,7 @@ end, true)
---@param _bufnr integer ---@param _bufnr integer
---@param pred string[] ---@param pred string[]
---@return boolean|nil ---@return boolean|nil
query.add_predicate("has-type?", function(match, _pattern, _bufnr, pred) query.add_predicate("kind-eq?", function(match, _pattern, _bufnr, pred)
if not valid_args(pred[1], pred, 2) then if not valid_args(pred[1], pred, 2) then
return return
end end

View file

@ -24,14 +24,14 @@
((for_statement ((for_statement
body: (_) @_body) @indent.begin body: (_) @_body) @indent.begin
(#not-has-type? @_body compound_statement)) (#not-kind-eq? @_body "compound_statement"))
(while_statement (while_statement
condition: (_) @indent.begin) condition: (_) @indent.begin)
((while_statement ((while_statement
body: (_) @_body) @indent.begin body: (_) @_body) @indent.begin
(#not-has-type? @_body compound_statement)) (#not-kind-eq? @_body "compound_statement"))
((if_statement) ((if_statement)
. .
@ -45,7 +45,7 @@
(if_statement (if_statement
consequence: (_ consequence: (_
";" @indent.end) @_consequence ";" @indent.end) @_consequence
(#not-has-type? @_consequence compound_statement) (#not-kind-eq? @_consequence "compound_statement")
alternative: (else_clause alternative: (else_clause
"else" @indent.branch "else" @indent.branch
[ [

View file

@ -29,15 +29,15 @@
(arrow_function (arrow_function
body: (_) @_body body: (_) @_body
(#not-has-type? @_body statement_block)) @indent.begin (#not-kind-eq? @_body "statement_block")) @indent.begin
(assignment_expression (assignment_expression
right: (_) @_right right: (_) @_right
(#not-has-type? @_right arrow_function function)) @indent.begin (#not-kind-eq? @_right "arrow_function" "function")) @indent.begin
(variable_declarator (variable_declarator
value: (_) @_value value: (_) @_value
(#not-has-type? @_value arrow_function call_expression function)) @indent.begin (#not-kind-eq? @_value "arrow_function" "call_expression" "function")) @indent.begin
(arguments (arguments
")" @indent.end) ")" @indent.end)

View file

@ -19,7 +19,7 @@
((for_loop ((for_loop
body: (_) @_body) @indent.begin body: (_) @_body) @indent.begin
(#not-has-type? @_body closure)) (#not-kind-eq? @_body "closure"))
; TODO: while, try ; TODO: while, try
(list (list

View file

@ -2,8 +2,8 @@
((foreach_statement ((foreach_statement
body: (_) @_body) @indent.begin body: (_) @_body) @indent.begin
(#not-has-type? @_body compound_statement)) (#not-kind-eq? @_body "compound_statement"))
((foreach_instance_statement ((foreach_instance_statement
body: (_) @_body) @indent.begin body: (_) @_body) @indent.begin
(#not-has-type? @_body compound_statement)) (#not-kind-eq? @_body "compound_statement"))

View file

@ -28,7 +28,7 @@
((else_clause ((else_clause
(_) @_not_if) @indent.begin (_) @_not_if) @indent.begin
(#not-has-type? @_not_if if_expression)) (#not-kind-eq? @_not_if "if_expression"))
((parameter) @indent.begin ((parameter) @indent.begin
(#set! indent.start_at_same_line)) (#set! indent.start_at_same_line))

View file

@ -66,7 +66,7 @@
(_)* @indent.branch) (_)* @indent.branch)
. .
_ @indent.branch _ @indent.branch
(#not-has-type? @indent.branch type_parameters parameter)) (#not-kind-eq? @indent.branch "type_parameters" "parameter"))
(ERROR (ERROR
[ [

View file

@ -13,7 +13,7 @@ else
files = vim.fn.split(vim.fn.glob(arg .. "/**/*.scm")) files = vim.fn.split(vim.fn.glob(arg .. "/**/*.scm"))
end end
ts.query.add_predicate("has-type?", function(match, _, _, pred) ts.query.add_predicate("kind-eq?", function(match, _, _, pred)
local node = match[pred[2]] local node = match[pred[2]]
if not node then if not node then
return true return true
@ -132,7 +132,7 @@ local format_queries = [[
;; 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 quantifier)) (#not-kind-eq? @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
@ -194,7 +194,7 @@ local format_queries = [[
] @format.cancel-append ] @format.cancel-append
. .
")" ")"
(#not-has-type? @format.cancel-append comment)) (#not-kind-eq? @format.cancel-append "comment"))
;; All captures should be separated with a space ;; All captures should be separated with a space
(capture) @format.prepend-space (capture) @format.prepend-space
@ -233,7 +233,7 @@ local format_queries = [[
;; Collapsing closing parens ;; Collapsing closing parens
(grouping (grouping
(_) @format.cancel-append . ")" (_) @format.cancel-append . ")"
(#not-has-type? @format.cancel-append comment)) (#not-kind-eq? @format.cancel-append "comment"))
(grouping (grouping
(capture) @format.prepend-space) (capture) @format.prepend-space)
;; Remove unnecessary parens ;; Remove unnecessary parens