Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/elixir/highlights.scm')
-rw-r--r--runtime/queries/elixir/highlights.scm271
1 files changed, 127 insertions, 144 deletions
diff --git a/runtime/queries/elixir/highlights.scm b/runtime/queries/elixir/highlights.scm
index c93accd0..08e09f37 100644
--- a/runtime/queries/elixir/highlights.scm
+++ b/runtime/queries/elixir/highlights.scm
@@ -15,67 +15,89 @@
; See the License for the specific language governing permissions and
; limitations under the License.
-; Punctuation
+; Reserved keywords
-[
- "%"
-] @punctuation
+["when" "and" "or" "not" "in" "not in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword
-[
- ","
- ";"
-] @punctuation.delimiter
+; Operators
-[
- "("
- ")"
- "["
- "]"
- "{"
- "}"
- "<<"
- ">>"
-] @punctuation.bracket
+; * doc string
+(unary_operator
+ operator: "@" @comment.block.documentation
+ operand: (call
+ target: (identifier) @comment.block.documentation.__attribute__
+ (arguments
+ [
+ (string) @comment.block.documentation
+ (charlist) @comment.block.documentation
+ (sigil
+ quoted_start: _ @comment.block.documentation
+ quoted_end: _ @comment.block.documentation) @comment.block.documentation
+ (boolean) @comment.block.documentation
+ ]))
+ (#match? @comment.block.documentation.__attribute__ "^(moduledoc|typedoc|doc)$"))
+
+; * module attribute
+(unary_operator
+ operator: "@" @variable.property
+ operand: [
+ (identifier) @variable.property
+ (call
+ target: (identifier) @variable.property)
+ (boolean) @variable.property
+ (nil) @variable.property
+ ])
+
+; * capture operator
+(unary_operator
+ operator: "&"
+ operand: [
+ (integer) @operator
+ (binary_operator
+ left: [
+ (call target: (dot left: (_) right: (identifier) @function))
+ (identifier) @function
+ ] operator: "/" right: (integer) @operator)
+ ])
+
+(operator_identifier) @operator
+
+(unary_operator
+ operator: _ @operator)
+
+(binary_operator
+ operator: _ @operator)
+
+(dot
+ operator: _ @operator)
+
+(stab_clause
+ operator: _ @operator)
; Literals
-(boolean) @constant.builtin.boolean
(nil) @constant.builtin
-(integer) @constant.numeric.integer
-(float) @constant.numeric.float
-(char) @constant.character
-; Identifiers
+(boolean) @constant.builtin.boolean
-; * regular
-(identifier) @variable
+[
+ (integer)
+ (float)
+] @number
-; * unused
-(
- (identifier) @comment.unused
- (#match? @comment.unused "^_")
-)
+(alias) @type
-; * special
-(
- (identifier) @constant.builtin
- (#any-of? @constant.builtin "__MODULE__" "__DIR__" "__ENV__" "__CALLER__" "__STACKTRACE__")
-)
-
-; Comment
+(call
+ target: (dot
+ left: (atom) @type))
-(comment) @comment
+(char) @constant.character
; Quoted content
-(interpolation "#{" @punctuation.special "}" @punctuation.special) @embedded
+(interpolation "#{" @escape "}" @escape) @embedded
-(escape_sequence) @constant.character.escape
-
-[
- (string)
- (charlist)
-] @string
+(escape_sequence) @escape
[
(atom)
@@ -84,12 +106,12 @@
(quoted_keyword)
] @string.special.symbol
-; Note that we explicitly target sigil quoted start/end, so they are not overridden by delimiters
+[
+ (string)
+ (charlist)
+] @string
-(sigil
- (sigil_name) @__name__
- quoted_start: _ @string.special
- quoted_end: _ @string.special) @string.special
+; Note that we explicitly target sigil quoted start/end, so they are not overridden by delimiters
(sigil
(sigil_name) @__name__
@@ -103,42 +125,32 @@
quoted_end: _ @string.regex
(#match? @__name__ "^[rR]$")) @string.regex
-; Calls
-
-; * local function call
-(call
- target: (identifier) @function)
-
-; * remote function call
-(call
- target: (dot
- right: (identifier) @function))
-
-; * field without parentheses or block
-(call
- target: (dot
- right: (identifier) @variable.other.member)
- .)
+(sigil
+ (sigil_name) @__name__
+ quoted_start: _ @string.special
+ quoted_end: _ @string.special) @string.special
-; * remote call without parentheses or block (overrides above)
-(call
- target: (dot
- left: [
- (alias)
- (atom)
- ]
- right: (identifier) @function)
- .)
+; Calls
; * definition keyword
(call
target: (identifier) @keyword
- (#any-of? @keyword "def" "defdelegate" "defexception" "defguard" "defguardp" "defimpl" "defmacro" "defmacrop" "defmodule" "defn" "defnp" "defoverridable" "defp" "defprotocol" "defstruct"))
+ (#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
- (#any-of? @keyword "alias" "case" "cond" "for" "if" "import" "quote" "raise" "receive" "require" "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))
+ (#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
@@ -150,12 +162,7 @@
left: (identifier) @function
operator: "when")
])
- (#any-of? @keyword "def" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defp"))
-
-; * pipe into identifier (function call)
-(binary_operator
- operator: "|>"
- right: (identifier) @function)
+ (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
; * pipe into identifier (definition)
(call
@@ -164,78 +171,54 @@
(binary_operator
operator: "|>"
right: (identifier) @variable))
- (#any-of? @keyword "def" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defp"))
+ (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
-; * pipe into field without parentheses (function call)
+; * pipe into identifier (function call)
(binary_operator
operator: "|>"
- right: (call
- target: (dot
- right: (identifier) @function)))
-
-; Operators
-
-; * capture operand
-(unary_operator
- operator: "&"
- operand: [
- (integer) @operator
- (binary_operator
- left: [
- (call target: (dot left: (_) right: (identifier) @function))
- (identifier) @function
- ] operator: "/" right: (integer) @operator)
- ])
-
-(operator_identifier) @operator
+ right: (identifier) @function)
-(unary_operator
- operator: _ @operator)
+; Identifiers
-(binary_operator
- operator: _ @operator)
+; * special
+(
+ (identifier) @constant.builtin
+ (#match? @constant.builtin "^(__MODULE__|__DIR__|__ENV__|__CALLER__|__STACKTRACE__)$")
+)
-(dot
- operator: _ @operator)
+; * unused
+(
+ (identifier) @comment
+ (#match? @comment "^_")
+)
-(stab_clause
- operator: _ @operator)
+; * regular
+(identifier) @variable
-; * module attribute
-(unary_operator
- operator: "@" @variable.other.member
- operand: [
- (identifier) @variable.other.member
- (call
- target: (identifier) @variable.other.member)
- (boolean) @variable.other.member
- (nil) @variable.other.member
- ])
+; Comment
-; * doc string
-(unary_operator
- operator: "@" @comment.block.documentation
- operand: (call
- target: (identifier) @comment.block.documentation.__attribute__
- (arguments
- [
- (string) @comment.block.documentation
- (charlist) @comment.block.documentation
- (sigil
- quoted_start: _ @comment.block.documentation
- quoted_end: _ @comment.block.documentation) @comment.block.documentation
- (boolean) @comment.block.documentation
- ]))
- (#any-of? @comment.block.documentation.__attribute__ "moduledoc" "typedoc" "doc"))
+(comment) @comment
-; Module
+; Punctuation
-(alias) @namespace
+[
+ "%"
+] @punctuation
-(call
- target: (dot
- left: (atom) @namespace))
+[
+ ","
+ ";"
+] @punctuation.delimiter
-; Reserved keywords
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+ "<<"
+ ">>"
+] @punctuation.bracket
-["when" "and" "or" "not" "in" "not in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword
+(ERROR) @warning