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) ; * doc string
(unary_operator
(keyword operator: "@" @comment.doc
(keyword_string operand: (call
[(string_start) target: (identifier) @comment.doc.__attribute__
(string_content) (arguments
(string_end)] @tag)) [
(string) @comment.doc
[(atom_literal) (charlist) @comment.doc
(atom_start) (sigil
(atom_content) quoted_start: _ @comment.doc
(atom_end)] @tag quoted_end: _ @comment.doc) @comment.doc
(boolean) @comment.doc
[(comment) ]))
(unused_identifier)] @comment (#match? @comment.doc.__attribute__ "^(moduledoc|typedoc|doc)$"))
(escape_sequence) @escape ; * module attribute
(unary_operator
(call function: (function_identifier) @keyword operator: "@" @attribute
(#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)$")) operand: [
(identifier) @attribute
(call function: (function_identifier) @keyword (call
[(call target: (identifier) @attribute)
function: (function_identifier) @function (boolean) @attribute
(arguments (nil) @attribute
[(identifier) @variable.parameter ])
(_ (identifier) @variable.parameter)
(_ (_ (identifier) @variable.parameter)) ; * capture operand
(_ (_ (_ (identifier) @variable.parameter))) (unary_operator
(_ (_ (_ (_ (identifier) @variable.parameter)))) operator: "&"
(_ (_ (_ (_ (_ (identifier) @variable.parameter)))))])) operand: (integer) @operator)
(binary_op
left: (operator_identifier) @operator
(call
function: (function_identifier) @function (unary_operator
(arguments operator: _ @operator)
[(identifier) @variable.parameter
(_ (identifier) @variable.parameter) (binary_operator
(_ (_ (identifier) @variable.parameter)) operator: _ @operator)
(_ (_ (_ (identifier) @variable.parameter)))
(_ (_ (_ (_ (identifier) @variable.parameter)))) (dot
(_ (_ (_ (_ (_ (identifier) @variable.parameter)))))])) operator: _ @operator)
(stab_clause
operator: _ @operator)
; Literals
[
(boolean)
(nil)
] @constant
[
(integer)
(float)
] @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
[
(identifier) @function
(binary_operator
left: (identifier) @function
operator: "when") operator: "when")
(binary_op ])
left: (identifier) @variable.parameter (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
operator: _ @function
right: (identifier) @variable.parameter)] ; * pipe into identifier (definition)
(#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$")) (call
target: (identifier) @keyword
(call (function_identifier) @keyword (arguments
[(call (binary_operator
function: (function_identifier) @function) operator: "|>"
(identifier) @function right: (identifier) @variable))
(binary_op (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
left:
[(call ; * pipe into identifier (function call)
function: (function_identifier) @function) (binary_operator
(identifier) @function] operator: "|>"
operator: "when")] right: (identifier) @function)
(#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$"))
; Identifiers
(anonymous_function
(stab_expression ; * special
left: (bare_arguments (
[(identifier) @variable.parameter (identifier) @constant.builtin
(_ (identifier) @variable.parameter) (#match? @constant.builtin "^(__MODULE__|__DIR__|__ENV__|__CALLER__|__STACKTRACE__)$")
(_ (_ (identifier) @variable.parameter)) )
(_ (_ (_ (identifier) @variable.parameter)))
(_ (_ (_ (_ (identifier) @variable.parameter)))) ; * unused
(_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))) (
(identifier) @comment.unused
(unary_op (#match? @comment.unused "^_")
operator: "@" )
(call (identifier) @attribute
(heredoc ; * regular
[(heredoc_start) (identifier) @variable
(heredoc_content)
(heredoc_end)] @doc)) ; Comment
(#match? @attribute "^(doc|moduledoc)$"))
(comment) @comment
(module) @type
; Punctuation
(unary_op
operator: "@" @attribute [
[(call "%"
function: (function_identifier) @attribute) ] @punctuation
(identifier) @attribute])
(unary_op
operator: _ @operator)
(binary_op
operator: _ @operator)
(heredoc
[(heredoc_start)
(heredoc_content)
(heredoc_end)] @string)
(string
[(string_start)
(string_content)
(string_end)] @string)
(sigil_start) @string.special
(sigil_content) @string
(sigil_end) @string.special
(interpolation
"#{" @punctuation.special
"}" @punctuation.special)
[ [
"," ","
"->" ";"
"."
] @punctuation.delimiter ] @punctuation.delimiter
[ [
@ -132,7 +193,3 @@
"<<" "<<"
">>" ">>"
] @punctuation.bracket ] @punctuation.bracket
(special_identifier) @function.special
(ERROR) @warning

Loading…
Cancel
Save