helix-mirror/runtime/queries/erlang/highlights.scm

129 lines
2.6 KiB
Scheme
Raw Normal View History

2022-02-15 05:14:02 +04:00
; Attributes
; module declaration
(attribute
name: (atom) @keyword
(arguments (atom) @namespace)
(#match? @keyword "(module|behaviou?r)"))
2022-02-15 05:14:02 +04:00
(attribute
name: (atom) @keyword
(arguments
.
(atom) @namespace)
2022-02-15 05:14:02 +04:00
(#eq? @keyword "import"))
(attribute
name: (atom) @keyword
(arguments
.
[(atom) @type (macro)]
2022-02-15 05:14:02 +04:00
[
(tuple (atom)? @variable.other.member)
2022-02-15 05:14:02 +04:00
(tuple
(binary_operator
left: (atom) @variable.other.member
operator: ["=" "::"]))
2022-02-15 05:14:02 +04:00
(tuple
(binary_operator
left:
(binary_operator
left: (atom) @variable.other.member
operator: "=")
operator: "::"))
])
(#eq? @keyword "record"))
(attribute
name: (atom) @keyword
(arguments
.
[
(atom) @constant
(variable) @constant
2022-02-15 05:14:02 +04:00
(call
function:
[(variable) (atom)] @keyword.directive)
])
(#eq? @keyword "define"))
(attribute
name: (atom) @keyword
(arguments
(_) @keyword.directive)
(#match? @keyword "ifn?def"))
2022-02-15 05:14:02 +04:00
(attribute
name: (atom) @keyword
module: (atom) @namespace
(#match? @keyword "(spec|callback)"))
2022-02-15 05:14:02 +04:00
; Functions
2022-06-02 03:40:05 +04:00
(function_clause name: (atom) @function)
(call module: (atom) @namespace)
2022-02-15 05:14:02 +04:00
(call function: (atom) @function)
(stab_clause name: (atom) @function)
(function_capture module: (atom) @namespace)
2022-02-15 05:14:02 +04:00
(function_capture function: (atom) @function)
; Records
(record_content
(binary_operator
left: (atom) @variable.other.member
operator: "="))
(record field: (atom) @variable.other.member)
(record name: (atom) @type)
; Keywords
(attribute name: (atom) @keyword)
2022-02-15 05:14:02 +04:00
["case" "fun" "if" "of" "when" "end" "receive" "try" "catch" "after" "begin" "maybe"] @keyword
2022-02-15 05:14:02 +04:00
; Operators
(binary_operator
left: (atom) @function
operator: "/"
right: (integer) @constant.numeric.integer)
((binary_operator operator: _ @keyword.operator)
(#match? @keyword.operator "^\\w+$"))
((unary_operator operator: _ @keyword.operator)
(#match? @keyword.operator "^\\w+$"))
2022-02-15 05:14:02 +04:00
(binary_operator operator: _ @operator)
(unary_operator operator: _ @operator)
["/" ":" "->"] @operator
2022-02-15 05:14:02 +04:00
(tripledot) @comment.discard
(comment) @comment
; Macros
(macro
"?"+ @constant
name: (_) @constant
!arguments)
2022-02-15 05:14:02 +04:00
(macro
"?"+ @keyword.directive
name: (_) @keyword.directive)
; Comments
((variable) @comment.discard
(#match? @comment.discard "^_"))
2022-02-15 05:14:02 +04:00
; Basic types
(variable) @variable
(atom) @string.special.symbol
2022-02-15 05:14:02 +04:00
(string) @string
(character) @constant.character
(integer) @constant.numeric.integer
(float) @constant.numeric.float
; Punctuation
["," "." "-" ";"] @punctuation.delimiter
["(" ")" "#" "{" "}" "[" "]" "<<" ">>"] @punctuation.bracket
2022-02-15 05:14:02 +04:00
; (ERROR) @error