mirror of
https://github.com/nvim-treesitter/nvim-treesitter-context
synced 2024-09-16 22:24:04 +02:00
feat(elixir): add queries
This commit is contained in:
parent
e00d0545bf
commit
6183524ec0
2 changed files with 127 additions and 0 deletions
18
queries/elixir/context.scm
Normal file
18
queries/elixir/context.scm
Normal file
|
@ -0,0 +1,18 @@
|
|||
(binary_operator
|
||||
left: (_)
|
||||
right: (_) @context)
|
||||
|
||||
(pair
|
||||
key: (_)
|
||||
value: (_) @context)
|
||||
|
||||
((unary_operator
|
||||
operand: (call
|
||||
target: (identifier)
|
||||
(arguments (_)))) @_op (#lua-match? @_op "@[%w_]+")) @context
|
||||
|
||||
(stab_clause right: (body (_) @context.end)) @context
|
||||
|
||||
(call
|
||||
target: (identifier)
|
||||
(do_block (_) @context.end)) @context
|
109
test/text.ex
Normal file
109
test/text.ex
Normal file
|
@ -0,0 +1,109 @@
|
|||
defmodule Foo do
|
||||
@moduledoc """
|
||||
Some really long
|
||||
|
||||
|
||||
|
||||
|
||||
documentation.
|
||||
"""
|
||||
|
||||
@some_const ~w[
|
||||
hi
|
||||
i'm
|
||||
a
|
||||
big
|
||||
list
|
||||
sigil
|
||||
]
|
||||
|
||||
|
||||
|
||||
def run(%{
|
||||
multi: multi,
|
||||
line: line,
|
||||
function_clause: function_clause
|
||||
}) do
|
||||
|
||||
|
||||
|
||||
case line do
|
||||
|
||||
|
||||
{:ok, foos}->
|
||||
Enum.map(foos, fn
|
||||
{f, f2} ->
|
||||
|
||||
|
||||
|
||||
String.downcase(f2)
|
||||
|
||||
f ->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String.upcase(f)
|
||||
|
||||
end)
|
||||
|
||||
|
||||
_ ->
|
||||
with some_num <- Enum.random(1..100),
|
||||
another_num <- Enum.random(1..100) do
|
||||
# TODO: all of it
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
def stop(params) do
|
||||
%{
|
||||
foo: %{
|
||||
"alice" => "alice",
|
||||
"bob" => "bob",
|
||||
"carol" => "carol",
|
||||
"dave" => "dave",
|
||||
|
||||
|
||||
|
||||
"bar" => [
|
||||
:bing,
|
||||
%{
|
||||
"very deeply nested" => %{
|
||||
|
||||
|
||||
|
||||
"jk, even deeper" => %{
|
||||
|
||||
|
||||
|
||||
"one more" => %{
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
:bong,
|
||||
|
||||
|
||||
:bang
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue