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.scm264
1 files changed, 143 insertions, 121 deletions
diff --git a/runtime/queries/elixir/highlights.scm b/runtime/queries/elixir/highlights.scm
index db4c6476..c93accd0 100644
--- a/runtime/queries/elixir/highlights.scm
+++ b/runtime/queries/elixir/highlights.scm
@@ -15,80 +15,56 @@
; See the License for the specific language governing permissions and
; limitations under the License.
-; Reserved keywords
-
-["when" "and" "or" "not" "in" "not in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword
-
-; Operators
-
-; * 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"))
-
-; * 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
- ])
-
-; * 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)
+; Punctuation
-(binary_operator
- operator: _ @operator)
+[
+ "%"
+] @punctuation
-(dot
- operator: _ @operator)
+[
+ ","
+ ";"
+] @punctuation.delimiter
-(stab_clause
- operator: _ @operator)
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+ "<<"
+ ">>"
+] @punctuation.bracket
; Literals
-(nil) @constant.builtin
-
(boolean) @constant.builtin.boolean
+(nil) @constant.builtin
(integer) @constant.numeric.integer
(float) @constant.numeric.float
+(char) @constant.character
-(alias) @namespace
+; Identifiers
-(call
- target: (dot
- left: (atom) @namespace))
+; * regular
+(identifier) @variable
-(char) @constant.character
+; * unused
+(
+ (identifier) @comment.unused
+ (#match? @comment.unused "^_")
+)
+
+; * special
+(
+ (identifier) @constant.builtin
+ (#any-of? @constant.builtin "__MODULE__" "__DIR__" "__ENV__" "__CALLER__" "__STACKTRACE__")
+)
+
+; Comment
+
+(comment) @comment
; Quoted content
@@ -97,38 +73,63 @@
(escape_sequence) @constant.character.escape
[
+ (string)
+ (charlist)
+] @string
+
+[
(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
- (#any-of? @__name__ "s" "S")) @string
+ quoted_start: _ @string.special
+ quoted_end: _ @string.special) @string.special
(sigil
(sigil_name) @__name__
- quoted_start: _ @string.regexp
- quoted_end: _ @string.regexp
- (#any-of? @__name__ "r" "R")) @string.regexp
+ quoted_start: _ @string
+ quoted_end: _ @string
+ (#match? @__name__ "^[sS]$")) @string
(sigil
(sigil_name) @__name__
- quoted_start: _ @string.special
- quoted_end: _ @string.special) @string.special
+ quoted_start: _ @string.regex
+ 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)
+ .)
+
+; * remote call without parentheses or block (overrides above)
+(call
+ target: (dot
+ left: [
+ (alias)
+ (atom)
+ ]
+ right: (identifier) @function)
+ .)
+
; * definition keyword
(call
target: (identifier) @keyword
@@ -137,17 +138,7 @@
; * kernel or special forms keyword
(call
target: (identifier) @keyword
- (#any-of? @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)
- ])
+ (#any-of? @keyword "alias" "case" "cond" "for" "if" "import" "quote" "raise" "receive" "require" "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))
; * just identifier in function definition
(call
@@ -161,6 +152,11 @@
])
(#any-of? @keyword "def" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defp"))
+; * pipe into identifier (function call)
+(binary_operator
+ operator: "|>"
+ right: (identifier) @function)
+
; * pipe into identifier (definition)
(call
target: (identifier) @keyword
@@ -170,50 +166,76 @@
right: (identifier) @variable))
(#any-of? @keyword "def" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defp"))
-; * pipe into identifier (function call)
+; * pipe into field without parentheses (function call)
(binary_operator
operator: "|>"
- right: (identifier) @function)
+ right: (call
+ target: (dot
+ right: (identifier) @function)))
-; Identifiers
+; Operators
-; * special
-(
- (identifier) @constant.builtin
- (#any-of? @constant.builtin "__MODULE__" "__DIR__" "__ENV__" "__CALLER__" "__STACKTRACE__")
-)
+; * capture operand
+(unary_operator
+ operator: "&"
+ operand: [
+ (integer) @operator
+ (binary_operator
+ left: [
+ (call target: (dot left: (_) right: (identifier) @function))
+ (identifier) @function
+ ] operator: "/" right: (integer) @operator)
+ ])
-; * unused
-(
- (identifier) @comment
- (#match? @comment "^_")
-)
+(operator_identifier) @operator
-; * regular
-(identifier) @variable
+(unary_operator
+ operator: _ @operator)
-; Comment
+(binary_operator
+ operator: _ @operator)
-(comment) @comment
+(dot
+ operator: _ @operator)
-; Punctuation
+(stab_clause
+ operator: _ @operator)
-[
- "%"
-] @punctuation
+; * 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
+ ])
-[
- ","
- ";"
-] @punctuation.delimiter
+; * 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"))
-[
- "("
- ")"
- "["
- "]"
- "{"
- "}"
- "<<"
- ">>"
-] @punctuation.bracket
+; Module
+
+(alias) @namespace
+
+(call
+ target: (dot
+ left: (atom) @namespace))
+
+; Reserved keywords
+
+["when" "and" "or" "not" "in" "not in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword