mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Initial Elixir support
This commit is contained in:
parent
506e998da2
commit
e7e1db38cd
6 changed files with 323 additions and 0 deletions
|
|
@ -146,6 +146,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @Akin909)
|
||||
- [x] [devicetree](https://github.com/joelspadin/tree-sitter-devicetree) (maintained by @jedrzejboczar)
|
||||
- [x] [dockerfile](https://github.com/camdencheek/tree-sitter-dockerfile) (maintained by @camdencheek)
|
||||
- [x] [elixir](https://github.com/ananthakumaran/tree-sitter-elixir) (maintained by @nifoc)
|
||||
- [ ] [elm](https://github.com/elm-tooling/tree-sitter-elm)
|
||||
- [x] [erlang](https://github.com/AbstractMachinesLab/tree-sitter-erlang) (maintained by @ostera)
|
||||
- [x] [fennel](https://github.com/travonted/tree-sitter-fennel) (maintained by @TravonteD)
|
||||
|
|
|
|||
|
|
@ -238,6 +238,14 @@ list.erlang = {
|
|||
maintainers = { '@ostera' },
|
||||
}
|
||||
|
||||
list.elixir = {
|
||||
install_info = {
|
||||
url = "https://github.com/ananthakumaran/tree-sitter-elixir",
|
||||
files = { "src/parser.c", "src/scanner.cc" },
|
||||
},
|
||||
maintainers = { '@nifoc' },
|
||||
}
|
||||
|
||||
list.ocaml = {
|
||||
install_info = {
|
||||
url = "https://github.com/tree-sitter/tree-sitter-ocaml",
|
||||
|
|
|
|||
190
queries/elixir/highlights.scm
Normal file
190
queries/elixir/highlights.scm
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
(identifier) @variable
|
||||
|
||||
(interpolation
|
||||
"#{" @punctuation.special
|
||||
"}" @punctuation.special) @none
|
||||
|
||||
[
|
||||
"after"
|
||||
"do"
|
||||
"end"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"and"
|
||||
"in"
|
||||
"not"
|
||||
"not in"
|
||||
"or"
|
||||
] @keyword.operator
|
||||
|
||||
(call (function_identifier) @method)
|
||||
|
||||
(call (function_identifier) @keyword
|
||||
(#any-of? @keyword
|
||||
"quote"
|
||||
"receive"
|
||||
"self"
|
||||
"super"
|
||||
"unquote"
|
||||
"unquote_splicing"
|
||||
"with"
|
||||
"assert"
|
||||
"assert_in_delta"
|
||||
"assert_raise"
|
||||
"assert_receive"
|
||||
"assert_received"
|
||||
"catch_error"
|
||||
"catch_exit"
|
||||
"catch_throw"
|
||||
"flunk"
|
||||
"refute"
|
||||
"refute_in_delta"
|
||||
"refute_receive"
|
||||
"refute_received"))
|
||||
|
||||
"fn" @keyword.function
|
||||
|
||||
(call (function_identifier) @keyword.function
|
||||
(#lua-match? @keyword.function "^def%a*$"))
|
||||
|
||||
(call (function_identifier) @keyword.function
|
||||
(#any-of? @keyword.function "describe" "doctest" "on_exit" "setup" "setup_all" "test"))
|
||||
|
||||
"else" @conditional
|
||||
|
||||
(call (function_identifier) @conditional
|
||||
(#any-of? @conditional "case" "cond" "if" "unless"))
|
||||
|
||||
(call (function_identifier) @repeat
|
||||
(#eq? @repeat "for"))
|
||||
|
||||
(call (function_identifier) @include
|
||||
(#any-of? @include "alias" "import" "require" "use"))
|
||||
|
||||
[
|
||||
"catch"
|
||||
"rescue"
|
||||
] @exception
|
||||
|
||||
(call (function_identifier) @exception
|
||||
(#any-of? @exception "raise" "try"))
|
||||
|
||||
[
|
||||
(heredoc_content)
|
||||
(sigil_content)
|
||||
(string_content)
|
||||
(string_end)
|
||||
(string_start)
|
||||
] @string
|
||||
|
||||
[
|
||||
(heredoc_end)
|
||||
(heredoc_start)
|
||||
(sigil_end)
|
||||
(sigil_start)
|
||||
] @string.special
|
||||
|
||||
(sigil
|
||||
(sigil_start) @_sigil-type
|
||||
[(sigil_content) (escape_sequence)] @string.regex
|
||||
(sigil_end)
|
||||
(#lua-match? @_sigil-type "^~r"))
|
||||
|
||||
(module) @type
|
||||
|
||||
[(atom) (keyword)] @symbol
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
(integer) @number
|
||||
(float) @float
|
||||
|
||||
[(true) (false)] @boolean
|
||||
|
||||
(nil) @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
|
||||
"->" @operator
|
||||
|
||||
(unary_op
|
||||
operator: _ @operator)
|
||||
|
||||
(binary_op
|
||||
operator: _ @operator)
|
||||
|
||||
(unary_op
|
||||
operator: "@" @attribute
|
||||
[(call
|
||||
function: (function_identifier) @attribute)
|
||||
(identifier) @attribute])
|
||||
|
||||
(unary_op
|
||||
operator: "@"
|
||||
(call (function_identifier) @attribute
|
||||
(heredoc
|
||||
[(heredoc_start)
|
||||
(heredoc_content)
|
||||
(heredoc_end)] @string))
|
||||
(#any-of? @attribute "doc" "moduledoc"))
|
||||
|
||||
(unary_op
|
||||
operator: "@"
|
||||
(call (function_identifier) @attribute
|
||||
(binary_op
|
||||
left: (identifier) @method))
|
||||
(#eq? @attribute "spec"))
|
||||
|
||||
[
|
||||
","
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"<<"
|
||||
">>"
|
||||
] @punctuation.bracket
|
||||
|
||||
(dot_call
|
||||
remote: [(atom) (module)] @type
|
||||
function: (function_identifier) @method)
|
||||
|
||||
(call (function_identifier) @keyword.function
|
||||
[(call
|
||||
(function_identifier) @function)
|
||||
(call
|
||||
function: (function_identifier) @function
|
||||
(arguments
|
||||
[(identifier) @parameter
|
||||
(binary_op
|
||||
left: (identifier) @parameter)]))
|
||||
(identifier) @function
|
||||
(binary_op
|
||||
left:
|
||||
[(call
|
||||
function: (function_identifier) @function
|
||||
(arguments
|
||||
[(identifier) @parameter
|
||||
(binary_op
|
||||
left: (identifier) @parameter)]))
|
||||
(identifier) @function]
|
||||
operator: "when")
|
||||
(binary_op
|
||||
left: (identifier)
|
||||
operator: _ @function
|
||||
right: (identifier))]
|
||||
(#lua-match? @keyword.function "^def%a*$"))
|
||||
|
||||
((identifier) @comment
|
||||
(#lua-match? @comment "^_[%a%d_]*$"))
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#lua-match? @constant.builtin "^__[%a%d_]+__$"))
|
||||
|
||||
(ERROR) @error
|
||||
28
queries/elixir/indents.scm
Normal file
28
queries/elixir/indents.scm
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
[
|
||||
(arguments)
|
||||
(call)
|
||||
(do_block)
|
||||
(list)
|
||||
(map)
|
||||
(stab_expression)
|
||||
] @indent
|
||||
|
||||
(stab_expression
|
||||
right: (_) @indent)
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
(after_block)
|
||||
(catch_block)
|
||||
(else_block)
|
||||
(rescue_block)
|
||||
"do"
|
||||
"end"
|
||||
] @branch
|
||||
|
||||
(comment) @ignore
|
||||
1
queries/elixir/injections.scm
Normal file
1
queries/elixir/injections.scm
Normal file
|
|
@ -0,0 +1 @@
|
|||
(comment) @comment
|
||||
95
queries/elixir/locals.scm
Normal file
95
queries/elixir/locals.scm
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
[
|
||||
(after_block)
|
||||
(catch_block)
|
||||
(do_block)
|
||||
(stab_expression)
|
||||
(rescue_block)
|
||||
] @scope
|
||||
|
||||
(identifier) @reference
|
||||
|
||||
(call
|
||||
function: (function_identifier) @_call-name
|
||||
(module) @definition.type
|
||||
(#eq? @_call-name "defmodule"))
|
||||
|
||||
(call
|
||||
function: (function_identifier) @_call-name
|
||||
(call
|
||||
function: (function_identifier) @definition.function)
|
||||
(#lua-match? @_call-name "^defp?$"))
|
||||
|
||||
(call
|
||||
function: (function_identifier) @_call-name
|
||||
(call
|
||||
function: (function_identifier) @definition.function
|
||||
(arguments
|
||||
[(identifier) @definition.parameter
|
||||
(tuple
|
||||
(identifier) @definition.parameter)
|
||||
(list
|
||||
(identifier) @definition.parameter)
|
||||
(map
|
||||
(keyword_list
|
||||
(identifier) @definition.parameter))
|
||||
(struct
|
||||
(keyword_list
|
||||
(identifier) @definition.parameter))
|
||||
(binary_op
|
||||
left: (identifier) @definition.parameter
|
||||
operator: "\\\\")]
|
||||
(#lua-match? @definition.parameter "^[^_]")))
|
||||
(#lua-match? @_call-name "^defp?$"))
|
||||
|
||||
(call
|
||||
function: (function_identifier) @_call-name
|
||||
(binary_op
|
||||
left: (call
|
||||
function: (function_identifier) @definition.function
|
||||
(arguments
|
||||
[(identifier) @definition.parameter
|
||||
(tuple
|
||||
(identifier) @definition.parameter)
|
||||
(list
|
||||
(identifier) @definition.parameter)
|
||||
(map
|
||||
(keyword_list
|
||||
(identifier) @definition.parameter))
|
||||
(struct
|
||||
(keyword_list
|
||||
(identifier) @definition.parameter))]
|
||||
(#lua-match? @definition.parameter "^[^_]")))
|
||||
operator: "when")
|
||||
(#lua-match? @_call-name "^defp?$"))
|
||||
|
||||
(binary_op
|
||||
left:
|
||||
[(identifier) @definition.var
|
||||
(tuple
|
||||
(identifier) @definition.var)
|
||||
(list
|
||||
(identifier) @definition.var)
|
||||
(map
|
||||
(keyword_list
|
||||
(identifier) @definition.var))
|
||||
(struct
|
||||
(keyword_list
|
||||
(identifier) @definition.var))]
|
||||
operator: "="
|
||||
(#lua-match? @definition.var "^[^_]"))
|
||||
|
||||
(stab_expression
|
||||
left:
|
||||
(bare_arguments
|
||||
[(identifier) @definition.var
|
||||
(tuple
|
||||
(identifier) @definition.var)
|
||||
(list
|
||||
(identifier) @definition.var)
|
||||
(map
|
||||
(keyword_list
|
||||
(identifier) @definition.var))
|
||||
(struct
|
||||
(keyword_list
|
||||
(identifier) @definition.var))])
|
||||
(#lua-match? @definition.var "^[^_]"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue