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

imgbot
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
(escape_sequence) @escape (unary_operator
operator: _ @operator)
(call function: (function_identifier) @keyword (binary_operator
(#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 (dot
[(call operator: _ @operator)
function: (function_identifier) @function
(arguments (stab_clause
[(identifier) @variable.parameter operator: _ @operator)
(_ (identifier) @variable.parameter)
(_ (_ (identifier) @variable.parameter)) ; Literals
(_ (_ (_ (identifier) @variable.parameter)))
(_ (_ (_ (_ (identifier) @variable.parameter)))) [
(_ (_ (_ (_ (_ (identifier) @variable.parameter)))))])) (boolean)
(binary_op (nil)
left: ] @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 (call
function: (function_identifier) @function 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
(heredoc ; * special
[(heredoc_start) (
(heredoc_content) (identifier) @constant.builtin
(heredoc_end)] @string) (#match? @constant.builtin "^(__MODULE__|__DIR__|__ENV__|__CALLER__|__STACKTRACE__)$")
)
(string ; * unused
[(string_start) (
(string_content) (identifier) @comment.unused
(string_end)] @string) (#match? @comment.unused "^_")
)
(sigil_start) @string.special ; * regular
(sigil_content) @string (identifier) @variable
(sigil_end) @string.special
(interpolation ; Comment
"#{" @punctuation.special
"}" @punctuation.special) (comment) @comment
; Punctuation
[
"%"
] @punctuation
[ [
"," ","
"->" ";"
"."
] @punctuation.delimiter ] @punctuation.delimiter
[ [
@ -132,7 +193,3 @@
"<<" "<<"
">>" ">>"
] @punctuation.bracket ] @punctuation.bracket
(special_identifier) @function.special
(ERROR) @warning

Loading…
Cancel
Save