Update highlights for new elixir-lang parser

This commit is contained in:
Connor Lay (Clay) 2021-10-05 19:35:18 -07:00 committed by Stephan Seitz
parent 1676efb9b7
commit e0125a5a1c

View file

@ -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" "and"
"catch"
"do"
"else"
"end"
"fn"
"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
[ [
(heredoc_content) "else"
(sigil_content) ] @conditional
(string)
] @string
; __MODULE__ and friends ; Comments
(special_identifier) @constant.builtin (comment) @comment
(map ["%{" "}"] @constructor) ; Parser errors
(ERROR) @error
(struct ["%" "{" "}"] @constructor) ; Sigils
(sigil (sigil_name) @operator quoted_start: _ @operator quoted_end: _ @operator)
(binary_op operator: _ @operator) ; Modules
(alias) @type
(unary_op operator: _ @operator)
(atom) @symbol
(keyword) @parameter
; Atoms
[ [
(true) (atom)
(false) (quoted_atom)
] @boolean ] @symbol
(nil) @constant.builtin ; Keywords
(keyword) @symbol
(sigil) @string.special ; Strings
(string) @string
(identifier) @variable ; Interpolation
(interpolation "#{" @string.escape (_)? "}" @string.escape)
(module) @type ; Escape sequences
(escape_sequence) @string.escape
(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"
)) ))
(call (function_identifier) @conditional (#any-of? @conditional ; Calling a local def function
(call target: ((identifier) @keyword.function (#match? @keyword.function
"^def(.*)?$"
)) (arguments (identifier) @function)?)
; 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"
)) ))