Skip to content

Commit

Permalink
Update tree-sitter queries to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
meain authored Sep 13, 2024
1 parent b4ef204 commit 14a35ee
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 170 deletions.
12 changes: 9 additions & 3 deletions queries/apex/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@
] @comment.outer

; assignment
(variable_declarator
name: (identifier) @assignment.lhs
value: (_) @assignment.rhs) @assignment.inner @assignment.outer
(field_declaration
(variable_declarator
name: (identifier) @assignment.lhs
value: (_) @assignment.rhs) @assignment.inner) @assignment.outer

(local_variable_declaration
(variable_declarator
name: (identifier) @assignment.lhs
value: (_) @assignment.rhs) @assignment.inner) @assignment.outer

12 changes: 12 additions & 0 deletions queries/c/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@

(if_statement) @conditional.outer

(if_statement
condition: (_) @conditional.inner
(#offset! @conditional.inner 0 1 0 -1))

(while_statement
condition: (_) @conditional.inner
(#offset! @conditional.inner 0 1 0 -1))

(do_statement
condition: (_) @conditional.inner
(#offset! @conditional.inner 0 1 0 -1))

(for_statement
condition: (_) @conditional.inner)

Expand Down
7 changes: 4 additions & 3 deletions queries/ecma/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@
; number
(number) @number.inner

(variable_declarator
name: (_) @assignment.lhs
value: (_) @assignment.inner @assignment.rhs) @assignment.outer
(lexical_declaration
(variable_declarator
name: (_) @assignment.lhs
value: (_) @assignment.inner @assignment.rhs)) @assignment.outer

(variable_declarator
name: (_) @assignment.inner)
Expand Down
8 changes: 7 additions & 1 deletion queries/fish/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
(function_definition) @function.outer
; assignment
(command
name: (word) @_command
argument: (word) @_varname @assignment.lhs @assignment.inner
argument: (_)* @assignment.rhs
(#not-lua-match? @_varname "[-].*")
(#eq? @_command "set")) @assignment.outer

(command
name: (word) @_name
Expand Down
34 changes: 19 additions & 15 deletions queries/go/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,23 @@
left: (_) @assignment.lhs
right: (_) @assignment.rhs @assignment.inner) @assignment.outer

(var_spec
name: (_) @assignment.lhs
value: (_) @assignment.rhs @assignment.inner) @assignment.outer

(var_spec
name: (_) @assignment.inner
type: (_)) @assignment.outer

(const_spec
name: (_) @assignment.lhs
value: (_) @assignment.rhs @assignment.inner) @assignment.outer

(const_spec
name: (_) @assignment.inner
type: (_)) @assignment.outer
(var_declaration
(var_spec
name: (_) @assignment.lhs
value: (_) @assignment.rhs @assignment.inner)) @assignment.outer

(var_declaration
(var_spec
name: (_) @assignment.inner
type: (_))) @assignment.outer

(const_declaration
(const_spec
name: (_) @assignment.lhs
value: (_) @assignment.rhs @assignment.inner)) @assignment.outer

(const_declaration
(const_spec
name: (_) @assignment.inner
type: (_))) @assignment.outer

84 changes: 53 additions & 31 deletions queries/haskell/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
((exp_apply
((apply
.
(exp_name)
function: (_)
.
(_) @call.inner._start
.
Expand All @@ -9,50 +9,71 @@
(_)? @call.inner._end .)
) @call.outer

(exp_infix
(infix
(_)
(variable)
[
(infix_id
(variable)) ; x `plus` y
(operator) ; x + y
]
(_)) @call.outer

(function
rhs: (_) @function.inner) @function.outer
(decl/function) @function.outer

(decl/function
patterns: (_)
.
match: (_) @function.inner._start
match: (_)? @function.inner._end
.
)

; also treat function signature as @function.outer
(signature) @function.outer

; treat signature with function as @function.outer
(((decl/signature
name: (_) @_sig_name) @function.outer._start
.
(decl/function
name: (_) @_func_name) @function.outer._end)
(#eq? @_sig_name @_func_name)
)

(class) @class.outer

(class
(class_body
(where)
_ @class.inner))
"where"
_ @class.inner)

(instance
(where)?
"where"?
.
_ @class.inner) @class.outer

(comment) @comment.outer

(exp_cond) @conditional.outer
(haddock) @comment.outer

(exp_cond
(expression/conditional) @conditional.outer

(expression/conditional
(_) @conditional.inner)

; e.g. forM [1..10] $ \i -> do...
(exp_infix
(exp_apply
(exp_name) @_name
(infix
(apply
(name) @_name
(#any-of? @_name "for" "for_" "forM" "forM_"))
(operator) @_op
(#eq? @_op "$")
(exp_lambda
(lambda
(_)
(_) @loop.inner)) @loop.outer

; e.g. forM [1..10] print
(exp_apply
(exp_name) @_name
(apply
(name) @_name
(#any-of? @_name "for" "for_" "forM" "forM_")
(_)
(_) @loop.inner) @loop.outer
Expand All @@ -65,35 +86,36 @@
; e.g. func mb@(Just x)
(function
(patterns
(pat_parens
(parens
(_) @parameter.inner)))

(function
(patterns
(pat_as
(pat_parens
(as
(parens
(_) @parameter.inner))))

(signature
(context
(fun
(type_apply) @parameter.inner)))
(function
(type/apply) @parameter.inner)))

(signature
(context
(fun
(type_name) @parameter.inner)))
(function
(type/name) @parameter.inner)))

(signature
(fun
(type_apply) @parameter.inner))
(function
(type/apply) @parameter.inner))

(signature
(fun
(type_name) @parameter.inner))
(function
(type/name) @parameter.inner))

(signature
(type_apply) @parameter.inner)
(type/apply) @parameter.inner)

(signature
(type_name) @parameter.inner)
(type/name) @parameter.inner)

21 changes: 17 additions & 4 deletions queries/julia/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,23 @@
)

; Assignment
(assignment
.
(_) @assignment.lhs
(_) @assignment.inner @assignment.rhs .) @assignment.outer
(local_statement
(assignment
.
(_) @assignment.lhs
(_) @assignment.inner @assignment.rhs .)) @assignment.outer

(const_statement
(assignment
.
(_) @assignment.lhs
(_) @assignment.inner @assignment.rhs .)) @assignment.outer

(global_statement
(assignment
.
(_) @assignment.lhs
(_) @assignment.inner @assignment.rhs .)) @assignment.outer

(assignment
.
Expand Down
5 changes: 3 additions & 2 deletions queries/php/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

(function_definition) @function.outer

(anonymous_function_creation_expression
(anonymous_function
body: (compound_statement
.
"{"
Expand All @@ -23,7 +23,7 @@
"}"
))

(anonymous_function_creation_expression) @function.outer
(anonymous_function) @function.outer

; methods
(method_declaration
Expand Down Expand Up @@ -313,3 +313,4 @@
(global_declaration)
(function_static_declaration)
] @statement.outer

Loading

0 comments on commit 14a35ee

Please sign in to comment.