Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add textobject queries for beam languages, capture rust closures as functions #2661

Merged
merged 4 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
| edoc | ✓ | | | |
| eex | ✓ | | | |
| ejs | ✓ | | | |
| elixir | ✓ | | | `elixir-ls` |
| elixir | ✓ | | | `elixir-ls` |
| elm | ✓ | | | `elm-language-server` |
| erb | ✓ | | | |
| erlang | ✓ | | | `erlang_ls` |
| erlang | ✓ | | | `erlang_ls` |
| fish | ✓ | ✓ | ✓ | |
| gdscript | ✓ | | ✓ | |
| git-attributes | ✓ | | | |
Expand All @@ -27,7 +27,7 @@
| git-diff | ✓ | | | |
| git-ignore | ✓ | | | |
| git-rebase | ✓ | | | |
| gleam | ✓ | | | |
| gleam | ✓ | | | |
| glsl | ✓ | | ✓ | |
| go | ✓ | ✓ | ✓ | `gopls` |
| gomod | ✓ | | | `gopls` |
Expand Down
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ language-server = { command = "erlang_ls" }

[[grammar]]
name = "erlang"
source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "481e7f8ddf27f07a47d1531b6e2b154b89ece31d" }
source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "c0ebc82600caaf4339f2b00691f958e9df97c065" }

[[language]]
name = "kotlin"
Expand Down
27 changes: 27 additions & 0 deletions runtime/queries/elixir/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
; Function heads and guards have no body at all, so `keywords` and `do_block` nodes are both optional
((call
target: (identifier) @_keyword
(arguments
[
(call
(arguments (_)? @parameter.inside))
; function has a guard
(binary_operator
left:
(call
(arguments (_)? @parameter.inside)))
]
; body is "do: body" instead of a do-block
(keywords
(pair
value: (_) @function.inside))?)?
(do_block (_)* @function.inside)?)
(#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp|test|describe|setup)$")) @function.around

(anonymous_function
(stab_clause right: (body) @function.inside)) @function.around

((call
target: (identifier) @_keyword
(do_block (_)* @class.inside))
(#match? @_keyword "^(defmodule|defprotocol|defimpl)$")) @class.around
2 changes: 1 addition & 1 deletion runtime/queries/erlang/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
(#eq? @keyword "(spec|callback)"))

; Functions
(function name: (atom) @function)
(function_clause name: (atom) @function)
(call module: (atom) @module)
(call function: (atom) @function)
(stab_clause name: (atom) @function)
Expand Down
8 changes: 8 additions & 0 deletions runtime/queries/erlang/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(function_clause
pattern: (arguments (_)? @parameter.inside)
body: (_) @function.inside) @function.around

(anonymous_function
(stab_clause body: (_) @function.inside)) @function.around

(comment (comment_content) @comment.inside) @comment.around
6 changes: 6 additions & 0 deletions runtime/queries/gleam/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(function
parameters: (function_parameters (function_parameter)? @parameter.inside)
body: (function_body) @function.inside) @function.around

(anonymous_function
body: (function_body) @function.inside) @function.around
2 changes: 2 additions & 0 deletions runtime/queries/rust/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
(function_item
body: (_) @function.inside)) @function.around

(closure_expression body: (_) @function.inside) @function.around

(
[
(attribute_item)+
Expand Down