mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-15 18:00:07 -04:00
Update highlights for new elixir-lang parser
This commit is contained in:
parent
1676efb9b7
commit
e0125a5a1c
1 changed files with 148 additions and 103 deletions
|
|
@ -1,5 +1,10 @@
|
||||||
(ERROR) @error
|
; Punctuation delimiters
|
||||||
|
[
|
||||||
|
"%"
|
||||||
|
","
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
; Punctuation brackets
|
||||||
[
|
[
|
||||||
"("
|
"("
|
||||||
")"
|
")"
|
||||||
|
|
@ -11,144 +16,184 @@
|
||||||
"}"
|
"}"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
; Operators
|
||||||
[
|
[
|
||||||
","
|
"!"
|
||||||
"->"
|
"!="
|
||||||
|
"!=="
|
||||||
|
"&"
|
||||||
|
"&&"
|
||||||
|
"&&&"
|
||||||
|
"*"
|
||||||
|
"**"
|
||||||
|
"+"
|
||||||
|
"++"
|
||||||
|
"+++"
|
||||||
|
"-"
|
||||||
|
"--"
|
||||||
|
"---"
|
||||||
"."
|
"."
|
||||||
] @punctuation.delimiter
|
".."
|
||||||
|
"/"
|
||||||
[
|
"//"
|
||||||
(sigil_start)
|
"::"
|
||||||
(sigil_end)
|
"<"
|
||||||
(heredoc_start)
|
"<-"
|
||||||
(heredoc_end)
|
"<<<"
|
||||||
] @punctuation.special
|
"<<~"
|
||||||
|
"<="
|
||||||
(interpolation ["#{" "}"] @punctuation.special)
|
"<>"
|
||||||
|
"<|>"
|
||||||
[
|
"<~"
|
||||||
"after"
|
"<~>"
|
||||||
"and"
|
"="
|
||||||
"catch"
|
"=="
|
||||||
"do"
|
"==="
|
||||||
"else"
|
"=>"
|
||||||
"end"
|
"=~"
|
||||||
"fn"
|
">"
|
||||||
|
">="
|
||||||
|
">>>"
|
||||||
|
"@"
|
||||||
|
"^"
|
||||||
|
"and"
|
||||||
"in"
|
"in"
|
||||||
"not in"
|
|
||||||
"not"
|
"not"
|
||||||
"or"
|
"or"
|
||||||
"rescue"
|
"when"
|
||||||
"when"
|
"|"
|
||||||
|
"|>"
|
||||||
|
"||"
|
||||||
|
"|||"
|
||||||
|
"~>"
|
||||||
|
"~>>"
|
||||||
|
"~~~"
|
||||||
|
"~"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
; Do/Fn blocks
|
||||||
|
[
|
||||||
|
"do"
|
||||||
|
"end"
|
||||||
|
"fn"
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
|
; Exception blocks
|
||||||
[
|
[
|
||||||
(comment)
|
"catch"
|
||||||
(unused_identifier)
|
"rescue"
|
||||||
] @comment
|
] @exception
|
||||||
|
|
||||||
|
; Conditional blocks
|
||||||
|
[
|
||||||
|
"else"
|
||||||
|
] @conditional
|
||||||
|
|
||||||
|
; Comments
|
||||||
|
(comment) @comment
|
||||||
|
|
||||||
|
; Parser errors
|
||||||
|
(ERROR) @error
|
||||||
|
|
||||||
|
; Sigils
|
||||||
|
(sigil (sigil_name) @operator quoted_start: _ @operator quoted_end: _ @operator)
|
||||||
|
|
||||||
|
; Modules
|
||||||
|
(alias) @type
|
||||||
|
|
||||||
|
; Atoms
|
||||||
[
|
[
|
||||||
(heredoc_content)
|
(atom)
|
||||||
(sigil_content)
|
(quoted_atom)
|
||||||
(string)
|
] @symbol
|
||||||
] @string
|
|
||||||
|
|
||||||
; __MODULE__ and friends
|
; Keywords
|
||||||
(special_identifier) @constant.builtin
|
(keyword) @symbol
|
||||||
|
|
||||||
(map ["%{" "}"] @constructor)
|
; Strings
|
||||||
|
(string) @string
|
||||||
|
|
||||||
(struct ["%" "{" "}"] @constructor)
|
; Interpolation
|
||||||
|
(interpolation "#{" @string.escape (_)? "}" @string.escape)
|
||||||
|
|
||||||
(binary_op operator: _ @operator)
|
; Escape sequences
|
||||||
|
(escape_sequence) @string.escape
|
||||||
(unary_op operator: _ @operator)
|
|
||||||
|
|
||||||
(atom) @symbol
|
|
||||||
|
|
||||||
(keyword) @parameter
|
|
||||||
|
|
||||||
[
|
|
||||||
(true)
|
|
||||||
(false)
|
|
||||||
] @boolean
|
|
||||||
|
|
||||||
(nil) @constant.builtin
|
|
||||||
|
|
||||||
(sigil) @string.special
|
|
||||||
|
|
||||||
(identifier) @variable
|
|
||||||
|
|
||||||
(module) @type
|
|
||||||
|
|
||||||
(function_identifier) @function
|
|
||||||
|
|
||||||
|
; Integers
|
||||||
(integer) @number
|
(integer) @number
|
||||||
|
|
||||||
|
; Floats
|
||||||
(float) @float
|
(float) @float
|
||||||
|
|
||||||
|
; Characters
|
||||||
[
|
[
|
||||||
(sigil_start)
|
(char)
|
||||||
(sigil_end)
|
(charlist)
|
||||||
] @string.special
|
] @character
|
||||||
|
|
||||||
; Module attributes as "attributes"
|
; Booleans
|
||||||
(unary_op operator: "@" @attribute [
|
(boolean) @boolean
|
||||||
(call function: (function_identifier) @attribute)
|
|
||||||
(identifier) @attribute
|
; Nil
|
||||||
|
(nil) @constant.builtin
|
||||||
|
|
||||||
|
; Calling a local function
|
||||||
|
(call target: (identifier) @function)
|
||||||
|
|
||||||
|
; Calling a remote function
|
||||||
|
(call target: (dot left: [
|
||||||
|
(atom) @type
|
||||||
|
(_)
|
||||||
|
] right: (identifier) @function) (arguments))
|
||||||
|
|
||||||
|
; Module attributes
|
||||||
|
(unary_operator operator: "@" @constant operand: [
|
||||||
|
(identifier) @constant
|
||||||
|
(call target: (identifier) @constant)
|
||||||
])
|
])
|
||||||
|
|
||||||
; Erlang modules (when they are the remote of a function call) are highlighted as Elixir modules
|
; Unused identifiers
|
||||||
(dot_call remote: (atom) @type)
|
((identifier) @comment (#match? @comment
|
||||||
|
"^_([^_].*)?$"
|
||||||
(call (function_identifier) @keyword.function (#any-of? @keyword.function
|
|
||||||
"def"
|
|
||||||
"defdelegate"
|
|
||||||
"defexception"
|
|
||||||
"defguard"
|
|
||||||
"defguardp"
|
|
||||||
"defimpl"
|
|
||||||
"defmacro"
|
|
||||||
"defmacrop"
|
|
||||||
"defmodule"
|
|
||||||
"defoverridable"
|
|
||||||
"defp"
|
|
||||||
"defprotocol"
|
|
||||||
"defstruct"
|
|
||||||
) [(identifier) @function (_)]) ; 0-arity function def without parens
|
|
||||||
|
|
||||||
(call (function_identifier) @include (#any-of? @include
|
|
||||||
"alias"
|
|
||||||
"import"
|
|
||||||
"require"
|
|
||||||
"use"
|
|
||||||
))
|
))
|
||||||
|
|
||||||
|
; Calling a local def function
|
||||||
|
(call target: ((identifier) @keyword.function (#match? @keyword.function
|
||||||
|
"^def(.*)?$"
|
||||||
|
)) (arguments (identifier) @function)?)
|
||||||
|
|
||||||
(call (function_identifier) @conditional (#any-of? @conditional
|
; Conditionals
|
||||||
|
(call target: (identifier) @conditional (#any-of? @conditional
|
||||||
"case"
|
"case"
|
||||||
"cond"
|
"cond"
|
||||||
"else"
|
|
||||||
"if"
|
"if"
|
||||||
|
"receive"
|
||||||
"unless"
|
"unless"
|
||||||
"with"
|
"with"
|
||||||
"receive"
|
|
||||||
))
|
))
|
||||||
|
|
||||||
(call (function_identifier) @exception (#any-of? @exception
|
; Comprehensions
|
||||||
|
(call target: (identifier) @repeat (#any-of? @repeat
|
||||||
|
"for"
|
||||||
|
))
|
||||||
|
|
||||||
|
; Exceptions
|
||||||
|
(call target: (identifier) @exception (#any-of? @exception
|
||||||
|
"after"
|
||||||
|
"catch"
|
||||||
|
"else"
|
||||||
"raise"
|
"raise"
|
||||||
"reraise"
|
"reraise"
|
||||||
|
"rescue"
|
||||||
"throw"
|
"throw"
|
||||||
"try"
|
"try"
|
||||||
))
|
))
|
||||||
|
|
||||||
(call (function_identifier) @repeat (#any-of? @repeat
|
; Special constants
|
||||||
"for"
|
((identifier) @constant.builtin (#any-of? @constant.builtin
|
||||||
))
|
"__CALLER__"
|
||||||
|
"__DIR__"
|
||||||
(call (function_identifier) @keyword.function (#any-of? @keyword.function
|
"__ENV__"
|
||||||
"describe"
|
"__MODULE__"
|
||||||
"setup"
|
"__STACKTRACE__"
|
||||||
"setup_all"
|
|
||||||
"test"
|
|
||||||
"using"
|
|
||||||
))
|
))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue