add highlights query from elixir-lang/tree-sitter-elixir

pull/830/head
Michael Davis 3 years ago
parent 6c0786edc5
commit d1b434d230
No known key found for this signature in database
GPG Key ID: 25D3AFE4BA2A0C49

@ -1,125 +1,186 @@
["when" "and" "or" "not in" "not" "in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword ; Reserved keywords
[(true) (false) (nil)] @constant.builtin ["when" "and" "or" "not" "in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword
(keyword ; Operators
[(keyword_literal)
":"] @tag)
(keyword ; * doc string
(keyword_string (unary_operator
[(string_start) operator: "@" @comment.doc
(string_content) operand: (call
(string_end)] @tag)) target: (identifier) @comment.doc.__attribute__
(arguments
[
(string) @comment.doc
(charlist) @comment.doc
(sigil
quoted_start: _ @comment.doc
quoted_end: _ @comment.doc) @comment.doc
(boolean) @comment.doc
]))
(#match? @comment.doc.__attribute__ "^(moduledoc|typedoc|doc)$"))
; * module attribute
(unary_operator
operator: "@" @attribute
operand: [
(identifier) @attribute
(call
target: (identifier) @attribute)
(boolean) @attribute
(nil) @attribute
])
[(atom_literal) ; * capture operand
(atom_start) (unary_operator
(atom_content) operator: "&"
(atom_end)] @tag operand: (integer) @operator)
[(comment) (operator_identifier) @operator
(unused_identifier)] @comment
(unary_operator
operator: _ @operator)
(escape_sequence) @escape (binary_operator
operator: _ @operator)
(call function: (function_identifier) @keyword (dot
(#match? @keyword "^(defmodule|defexception|defp|def|with|case|cond|raise|import|require|use|defmacrop|defmacro|defguardp|defguard|defdelegate|defstruct|alias|defimpl|defprotocol|defoverridable|receive|if|for|try|throw|unless|reraise|super|quote|unquote|unquote_splicing)$")) operator: _ @operator)
(call function: (function_identifier) @keyword (stab_clause
[(call operator: _ @operator)
function: (function_identifier) @function
(arguments ; Literals
[(identifier) @variable.parameter
(_ (identifier) @variable.parameter) [
(_ (_ (identifier) @variable.parameter)) (boolean)
(_ (_ (_ (identifier) @variable.parameter))) (nil)
(_ (_ (_ (_ (identifier) @variable.parameter)))) ] @constant
(_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
(binary_op [
left: (integer)
(call (float)
function: (function_identifier) @function ] @number
(alias) @type
(char) @constant
; Quoted content
(interpolation "#{" @punctuation.special "}" @punctuation.special) @embedded
(escape_sequence) @string.escape
[
(atom)
(quoted_atom)
(keyword)
(quoted_keyword)
] @string.special.symbol
[
(string)
(charlist)
] @string
; Note that we explicitly target sigil quoted start/end, so they are not overridden by delimiters
(sigil
(sigil_name) @__name__
quoted_start: _ @string
quoted_end: _ @string
(#match? @__name__ "^[sS]$")) @string
(sigil
(sigil_name) @__name__
quoted_start: _ @string.regex
quoted_end: _ @string.regex
(#match? @__name__ "^[rR]$")) @string.regex
(sigil
(sigil_name) @__name__
quoted_start: _ @string.special
quoted_end: _ @string.special) @string.special
; Calls
; * definition keyword
(call
target: (identifier) @keyword
(#match? @keyword "^(def|defdelegate|defexception|defguard|defguardp|defimpl|defmacro|defmacrop|defmodule|defn|defnp|defoverridable|defp|defprotocol|defstruct)$"))
; * kernel or special forms keyword
(call
target: (identifier) @keyword
(#match? @keyword "^(alias|case|cond|else|for|if|import|quote|raise|receive|require|reraise|super|throw|try|unless|unquote|unquote_splicing|use|with)$"))
; * function call
(call
target: [
; local
(identifier) @function
; remote
(dot
right: (identifier) @function)
])
; * just identifier in function definition
(call
target: (identifier) @keyword
(arguments (arguments
[(identifier) @variable.parameter [
(_ (identifier) @variable.parameter)
(_ (_ (identifier) @variable.parameter))
(_ (_ (_ (identifier) @variable.parameter)))
(_ (_ (_ (_ (identifier) @variable.parameter))))
(_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
operator: "when")
(binary_op
left: (identifier) @variable.parameter
operator: _ @function
right: (identifier) @variable.parameter)]
(#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$"))
(call (function_identifier) @keyword
[(call
function: (function_identifier) @function)
(identifier) @function (identifier) @function
(binary_op (binary_operator
left: left: (identifier) @function
[(call operator: "when")
function: (function_identifier) @function) ])
(identifier) @function] (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
operator: "when")]
(#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$"))
(anonymous_function
(stab_expression
left: (bare_arguments
[(identifier) @variable.parameter
(_ (identifier) @variable.parameter)
(_ (_ (identifier) @variable.parameter))
(_ (_ (_ (identifier) @variable.parameter)))
(_ (_ (_ (_ (identifier) @variable.parameter))))
(_ (_ (_ (_ (_ (identifier) @variable.parameter)))))])))
(unary_op
operator: "@"
(call (identifier) @attribute
(heredoc
[(heredoc_start)
(heredoc_content)
(heredoc_end)] @doc))
(#match? @attribute "^(doc|moduledoc)$"))
(module) @type
(unary_op
operator: "@" @attribute
[(call
function: (function_identifier) @attribute)
(identifier) @attribute])
(unary_op ; * pipe into identifier (definition)
operator: _ @operator) (call
target: (identifier) @keyword
(arguments
(binary_operator
operator: "|>"
right: (identifier) @variable))
(#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
(binary_op ; * pipe into identifier (function call)
operator: _ @operator) (binary_operator
operator: "|>"
right: (identifier) @function)
; Identifiers
; * special
(
(identifier) @constant.builtin
(#match? @constant.builtin "^(__MODULE__|__DIR__|__ENV__|__CALLER__|__STACKTRACE__)$")
)
; * unused
(
(identifier) @comment.unused
(#match? @comment.unused "^_")
)
(heredoc ; * regular
[(heredoc_start) (identifier) @variable
(heredoc_content)
(heredoc_end)] @string)
(string ; Comment
[(string_start)
(string_content)
(string_end)] @string)
(sigil_start) @string.special (comment) @comment
(sigil_content) @string
(sigil_end) @string.special
(interpolation ; Punctuation
"#{" @punctuation.special
"}" @punctuation.special) [
"%"
] @punctuation
[ [
"," ","
"->" ";"
"."
] @punctuation.delimiter ] @punctuation.delimiter
[ [
@ -132,7 +193,3 @@
"<<" "<<"
">>" ">>"
] @punctuation.bracket ] @punctuation.bracket
(special_identifier) @function.special
(ERROR) @warning

Loading…
Cancel
Save