1

Update generated neovim config

This commit is contained in:
2024-09-22 20:41:25 +02:00
parent 1743764e48
commit aa1271c42c
1247 changed files with 26512 additions and 15067 deletions

View File

@ -62,7 +62,7 @@
"using"
"concept"
"requires"
(virtual)
"virtual"
] @keyword
; Strings

View File

@ -0,0 +1,17 @@
; inherits: cpp
[
"<<<"
">>>"
] @punctuation.bracket
[
"__host__"
"__device__"
"__global__"
"__managed__"
"__forceinline__"
"__noinline__"
] @keyword.modifier
"__launch_bounds__" @keyword.modifier

View File

@ -1,177 +1,5 @@
; Methods
; --------------------
; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't
; specifically identify a node as a function call
(((identifier) @function (#match? @function "^_?[a-z]"))
. (selector . (argument_part))) @function
; Annotations
; --------------------
(annotation
name: (identifier) @attribute)
; Operators and Tokens
; --------------------
(template_substitution
"$" @punctuation.special
"{" @punctuation.special
"}" @punctuation.special
) @none
(template_substitution
"$" @punctuation.special
(identifier_dollar_escaped) @variable
) @none
(escape_sequence) @string.escape
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
(type_arguments
"<" @punctuation.bracket
">" @punctuation.bracket)
(type_parameters
"<" @punctuation.bracket
">" @punctuation.bracket)
[
"@"
"=>"
".."
"??"
"=="
"?"
":"
"&&"
"%"
"<"
">"
"="
">="
"<="
"||"
"~/"
(increment_operator)
(is_operator)
(prefix_operator)
(equality_operator)
(additive_operator)
] @operator
; Delimiters
; --------------------
[
";"
"."
","
] @punctuation.delimiter
; Types
; --------------------
((type_identifier) @type.builtin
(#match? @type.builtin "^(int|double|String|bool|List|Set|Map|Runes|Symbol)$"))
(type_identifier) @type
(class_definition
name: (identifier) @type)
(constructor_signature
name: (identifier) @type)
(scoped_identifier
scope: (identifier) @type)
(function_signature
name: (identifier) @function)
(getter_signature
(identifier) @function)
(setter_signature
name: (identifier) @function)
(type_identifier) @type
((scoped_identifier
scope: (identifier) @type
name: (identifier) @type)
(#match? @type "^[a-zA-Z]"))
; Enums
; -------------------
(enum_declaration
name: (identifier) @type)
(enum_constant
name: (identifier) @identifier.constant)
; Variables
; --------------------
; var keyword
(inferred_type) @keyword
((identifier) @type
(#match? @type "^_?[A-Z].*[a-z]"))
("Function" @type)
(this) @variable.builtin
; properties
((selector
(unconditional_assignable_selector (identifier) @function))
(selector (argument_part (arguments)))
)
(cascade_section
(cascade_selector (identifier) @function)
(argument_part (arguments))
)
(unconditional_assignable_selector
(identifier) @property)
(conditional_assignable_selector
(identifier) @property)
(cascade_section
(cascade_selector
(identifier) @property))
; assignments
(assignment_expression
left: (assignable_expression) @variable)
(this) @variable.builtin
; Parameters
; --------------------
(formal_parameter
name: (identifier) @identifier.parameter)
(named_argument
(label (identifier) @identifier.parameter))
; Literals
; --------------------
[
(hex_integer_literal)
(decimal_integer_literal)
(decimal_floating_point_literal)
; TODO: inaccessbile nodes
; (octal_integer_literal)
; (hex_floating_point_literal)
] @number
(string_literal) @string
(symbol_literal (identifier) @constant) @constant
(true) @boolean
(false) @boolean
(null_literal) @constant.null
(documentation_comment) @comment
(comment) @comment
; Variable
(identifier) @variable
; Keywords
; --------------------
@ -242,5 +70,177 @@
"yield"
] @keyword
; Variable
(identifier) @variable
; Methods
; --------------------
; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't
; specifically identify a node as a function call
(((identifier) @function (#match? @function "^_?[a-z]"))
. (selector . (argument_part))) @function
; Annotations
; --------------------
(annotation
name: (identifier) @attribute)
; Operators and Tokens
; --------------------
(template_substitution
"$" @punctuation.special
"{" @punctuation.special
"}" @punctuation.special
) @none
(template_substitution
"$" @punctuation.special
(identifier_dollar_escaped) @variable
) @none
(escape_sequence) @string.escape
[
"@"
"=>"
".."
"??"
"=="
"?"
":"
"&&"
"%"
"<"
">"
"="
">="
"<="
"||"
"~/"
(increment_operator)
(is_operator)
(prefix_operator)
(equality_operator)
(additive_operator)
] @operator
(type_arguments
"<" @punctuation.bracket
">" @punctuation.bracket)
(type_parameters
"<" @punctuation.bracket
">" @punctuation.bracket)
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
; Delimiters
; --------------------
[
";"
"."
","
] @punctuation.delimiter
; Types
; --------------------
(type_identifier) @type
((type_identifier) @type.builtin
(#match? @type.builtin "^(int|double|String|bool|List|Set|Map|Runes|Symbol)$"))
(class_definition
name: (identifier) @type)
(constructor_signature
name: (identifier) @type)
(scoped_identifier
scope: (identifier) @type)
(function_signature
name: (identifier) @function)
(getter_signature
(identifier) @function)
(setter_signature
name: (identifier) @function)
((scoped_identifier
scope: (identifier) @type
name: (identifier) @type)
(#match? @type "^[a-zA-Z]"))
; Enums
; -------------------
(enum_declaration
name: (identifier) @type)
(enum_constant
name: (identifier) @identifier.constant)
; Variables
; --------------------
; var keyword
(inferred_type) @keyword
((identifier) @type
(#match? @type "^_?[A-Z].*[a-z]"))
("Function" @type)
(this) @variable.builtin
; properties
(unconditional_assignable_selector
(identifier) @property)
(conditional_assignable_selector
(identifier) @property)
(cascade_section
(cascade_selector
(identifier) @property))
((selector
(unconditional_assignable_selector (identifier) @function))
(selector (argument_part (arguments)))
)
(cascade_section
(cascade_selector (identifier) @function)
(argument_part (arguments))
)
; assignments
(assignment_expression
left: (assignable_expression) @variable)
(this) @variable.builtin
; Parameters
; --------------------
(formal_parameter
name: (identifier) @identifier.parameter)
(named_argument
(label (identifier) @identifier.parameter))
; Literals
; --------------------
[
(hex_integer_literal)
(decimal_integer_literal)
(decimal_floating_point_literal)
; TODO: inaccessbile nodes
; (octal_integer_literal)
; (hex_floating_point_literal)
] @number
(string_literal) @string
(symbol_literal (identifier) @constant) @constant
(true) @boolean
(false) @boolean
(null_literal) @constant.null
(documentation_comment) @comment
(comment) @comment

View File

@ -0,0 +1,12 @@
[
(if_statement)
(elif_clause)
(else_clause)
(while_statement)
(repeat_statement)
(for_statement)
(atomic_statement)
(lambda)
(function)
(atomic_function)
] @fold

View File

@ -0,0 +1,219 @@
; NOTE: (reiniscirpons) in case multiple queries match, last query wins. So
; queries should go from least specific to most specific. (This is the default
; behaviour since tree-sitter 0.22.2)
(identifier) @variable
; Constants
; convention: constants are of the form ALL_CAPS_AND_UNDERSCORES and have length at least 2
((identifier) @constant
(#match? @constant "^[A-Z_][A-Z_]+$"))
; Functions
(assignment_statement
left: (identifier) @function
right: (function))
(assignment_statement
left: (identifier) @function
right: (atomic_function))
(assignment_statement
left: (identifier) @function
right: (lambda))
(call
function: (identifier) @function.call)
((call
function: (identifier) @function.builtin)
(#any-of? @function.builtin "Assert" "Info" "IsBound" "Unbind" "TryNextMethod"))
(parameters
(identifier) @variable.parameter)
(qualified_parameters
(identifier) @variable.parameter)
(qualified_parameters
(qualified_identifier
(identifier) @variable.parameter))
(lambda_parameters
(identifier) @variable.parameter)
; arg is treated specially when it is the only parameter of a function
((parameters
.
(identifier) @variable.parameter.builtin .)
(#eq? @variable.parameter.builtin "arg"))
((qualified_parameters
.
(identifier) @variable.parameter.builtin .)
(#eq? @variable.parameter.builtin "arg"))
((qualified_parameters
.
(qualified_identifier
(identifier) @variable.parameter.builtin) .)
(#eq? @variable.parameter.builtin "arg"))
((lambda_parameters
.
(identifier) @variable.parameter.builtin .)
(#eq? @variable.parameter.builtin "arg"))
(locals
(identifier) @variable.parameter)
; Literals
(bool) @constant.builtin
(integer) @number
(float) @number.float
(string) @string
(char) @character
(escape_sequence) @string.escape
[
(help_topic)
(help_book)
] @string.special
(tilde) @variable.builtin
; Record selectors
(record_entry
left: [
(identifier)
(integer)
] @variable.member)
(record_selector
selector: [
(identifier)
(integer)
] @variable.member)
(component_selector
selector: [
(identifier)
(integer)
] @variable.member)
(function_call_option
[
(identifier)
(record_entry ;Record entries specify global properties in function calls
left: [
(identifier)
(integer)
])
] @property)
(help_statement
(help_selector) @property)
; Operators
[
"+"
"-"
"*"
"/"
"^"
"->"
":="
"<"
"<="
"<>"
"="
">"
">="
".."
(ellipsis)
] @operator
(help_statement
(help_operator) @operator)
; Keywords
[
(break_statement)
(continue_statement)
"atomic"
(quit_statement)
] @keyword
[
"function"
"local"
"end"
] @keyword.function
[
"and"
"in"
"mod"
"not"
"or"
] @keyword.operator
"rec" @keyword.type
[
"readonly"
"readwrite"
] @keyword.modifier
(atomic_function
"atomic" @keyword.modifier)
[
"for"
"while"
"do"
"od"
"repeat"
"until"
] @keyword.repeat
[
"if"
"then"
"elif"
"else"
"fi"
] @keyword.conditional
"return" @keyword.return
(pragma) @keyword.directive
;Punctuation
[
","
";"
"."
"!."
":"
] @punctuation.delimiter
[
"("
")"
"["
"!["
"]"
"{"
"}"
] @punctuation.bracket
(help_statement
"?" @punctuation.special)
;Comments
(comment) @comment @spell

View File

@ -0,0 +1,45 @@
; The only other scopes apart from the global scope occur in function
; definitions.
[
(lambda)
(function)
(atomic_function)
] @local.scope
(parameters
(identifier) @local.definition.parameter)
(qualified_parameters
(identifier) @local.definition.parameter)
(qualified_parameters
(qualified_identifier
(identifier) @local.definition.parameter))
(lambda_parameters
(identifier) @local.definition.parameter)
(locals
(identifier) @local.definition.var)
(record_entry
left: [
(identifier)
(integer)
] @local.definition.field)
(assignment_statement
left: (identifier) @local.definition.var)
(for_statement
identifier: (identifier) @local.definition.var)
(assignment_statement
left: (identifier) @local.definition.function
right: [
(lambda)
(function)
(atomic_function)
])
(identifier) @local.reference

View File

@ -0,0 +1,43 @@
; Copy of `locals.scm` but using the tree-sitter official tags for local
; highlighting. This is necessary to avoid errors when testing with
; `tree-sitter test`.
; The only other scopes apart from the global scope occur in function
; definitions.
; TODO: (reiniscirpons) automatically generate this file from `locals.scm`
[
(lambda)
(function)
(atomic_function)
] @local.scope
(parameters
(identifier) @local.definition)
(qualified_parameters
(identifier) @local.definition)
(qualified_parameters
(qualified_identifier
(identifier) @local.definition))
(lambda_parameters
(identifier) @local.definition)
(locals
(identifier) @local.definition)
(assignment_statement
left: (identifier) @local.definition)
(for_statement
identifier: (identifier) @local.definition)
(assignment_statement
left: (identifier) @local.definition
right: [
(lambda)
(function)
(atomic_function)
])
(identifier) @local.reference

View File

@ -0,0 +1,17 @@
; TODO: (reiniscirpons) Add support for tagging function interfaces defined
; with `DeclareOperation` or `DeclareAttribute` etc. and implemented with
; `InstallMethod` etc.
; TODO: (reiniscirpons) Add support for Filter/Category stuff maybe using the
; @definition.class tag? Requires understanding GAP type system which I do not yet.
; TODO: (reiniscirpons) Figure out how to do module (i.e. package) tagging and
; whether that even makes sense for GAP.
(assignment_statement
left: (identifier) @name
right: [
(lambda)
(function)
(atomic_function)
]) @definition.function
(call
function: (identifier) @name) @reference.call

View File

@ -0,0 +1,7 @@
[
(if_statement)
(else_clause)
(local_statement)
(exec_statement)
(test_case)
] @fold

View File

@ -0,0 +1,17 @@
(output_line) @string.documentation
[
"#@local"
"#@exec"
] @keyword
[
"gap> "
"> "
] @keyword.debug
[
"#@if"
"#@else"
"#@fi"
] @keyword.conditional

View File

@ -0,0 +1,9 @@
([
(comment)
(gap_expression)
] @injection.content
(#set! injection.language "gap"))
((input_line) @injection.content
(#set! injection.language "gap")
(#set! injection.combined))

View File

@ -1,4 +1,6 @@
; Scopes
(block) @local.scope
(function) @local.scope
(case_clause) @local.scope

View File

@ -1,4 +0,0 @@
[
(element_node (element_node_start))
(block_statement)
] @fold

View File

@ -0,0 +1,5 @@
[
(element_node
(element_node_start))
(block_statement)
] @fold

View File

@ -0,0 +1,117 @@
; === Tag Names ===
; Tags that start with a lower case letter are HTML tags
; We'll also use this highlighting for named blocks (which start with `:`)
((tag_name) @tag
(#lua-match? @tag "^:?[%l]"))
; Tags that start with a capital letter are Glimmer components
((tag_name) @constructor
(#lua-match? @constructor "^%u"))
(attribute_name) @attribute
(string_literal) @string
(number_literal) @number
(boolean_literal) @boolean
(concat_statement) @string
; === Block Statements ===
; Highlight the brackets
(block_statement_start) @tag.delimiter
(block_statement_end) @tag.delimiter
; Highlight `if`/`each`/`let`
(block_statement_start
path: (identifier) @keyword.conditional)
(block_statement_end
path: (identifier) @keyword.conditional)
((mustache_statement
(identifier) @keyword.conditional)
(#lua-match? @keyword.conditional "else"))
; == Mustache Statements ===
; Highlight the whole statement, to color brackets and separators
(mustache_statement) @tag.delimiter
; An identifier in a mustache expression is a variable
((mustache_statement
[
(path_expression
(identifier) @variable)
(identifier) @variable
])
(#not-any-of? @variable "yield" "outlet" "this" "else"))
; As are arguments in a block statement
(block_statement_start
argument: [
(path_expression
(identifier) @variable)
(identifier) @variable
])
; As is an identifier in a block param
(block_params
(identifier) @variable)
; As are helper arguments
((helper_invocation
argument: [
(path_expression
(identifier) @variable)
(identifier) @variable
])
(#not-eq? @variable "this"))
; `this` should be highlighted as a built-in variable
((identifier) @variable.builtin
(#eq? @variable.builtin "this"))
; If the identifier is just "yield" or "outlet", it's a keyword
((mustache_statement
(identifier) @keyword)
(#any-of? @keyword "yield" "outlet"))
; Helpers are functions
((helper_invocation
helper: [
(path_expression
(identifier) @function)
(identifier) @function
])
(#not-any-of? @function "if" "yield"))
((helper_invocation
helper: (identifier) @keyword.conditional)
(#eq? @keyword.conditional "if"))
((helper_invocation
helper: (identifier) @keyword)
(#eq? @keyword "yield"))
(hash_pair
key: (identifier) @property)
(comment_statement) @comment @spell
(attribute_node
"=" @operator)
(block_params
"as" @keyword)
(block_params
"|" @operator)
[
"<"
">"
"</"
"/>"
] @tag.delimiter

View File

@ -0,0 +1,34 @@
[
(element_node
(element_node_start))
(element_node_void)
(block_statement
(block_statement_start))
(mustache_statement)
] @indent.begin
(element_node
(element_node_end
">" @indent.end))
(element_node_void
"/>" @indent.end)
[
">"
"/>"
"</"
"{{/"
"}}"
] @indent.branch
(mustache_statement
(helper_invocation
helper: (identifier) @_identifier
(#eq? @_identifier "else"))) @indent.branch
(mustache_statement
((identifier) @_identifier
(#eq? @_identifier "else"))) @indent.branch
(comment_statement) @indent.ignore

View File

@ -0,0 +1,21 @@
; comments
((comment_statement) @injection.content
(#set! injection.language "comment"))
; <style> tags
((element_node
(element_node_start
(tag_name) @_tag_name
(#eq? @_tag_name "style"))) @injection.content
(#offset! @injection.content 0 7 0 -8)
(#set! injection.language "css")
(#set! injection.include-children))
; <script> tags
((element_node
(element_node_start
(tag_name) @_tag_name
(#eq? @_tag_name "script"))) @injection.content
(#offset! @injection.content 0 8 0 -9)
(#set! injection.language "glimmer_javascript")
(#set! injection.include-children))

View File

@ -1,88 +0,0 @@
; === Tag Names ===
; Tags that start with a lower case letter are HTML tags
; We'll also use this highlighting for named blocks (which start with `:`)
((tag_name) @tag
(#match? @tag "^(:)?[a-z]"))
; Tags that start with a capital letter are Glimmer components
((tag_name) @constructor
(#match? @constructor "^[A-Z]"))
(attribute_name) @property
(string_literal) @string
(number_literal) @number
(boolean_literal) @boolean
(concat_statement) @string
; === Block Statements ===
; Highlight the brackets
(block_statement_start) @tag.delimiter
(block_statement_end) @tag.delimiter
; Highlight `if`/`each`/`let`
(block_statement_start path: (identifier) @conditional)
(block_statement_end path: (identifier) @conditional)
((mustache_statement (identifier) @conditional)
(#match? @conditional "else"))
; == Mustache Statements ===
; Hightlight the whole statement, to color brackets and separators
(mustache_statement) @tag.delimiter
; An identifier in a mustache expression is a variable
((mustache_statement [
(path_expression (identifier) @variable)
(identifier) @variable
])
(#not-match? @variable "yield|outlet|this|else"))
; As are arguments in a block statement
(block_statement_start argument: [
(path_expression (identifier) @variable)
(identifier) @variable
])
; As is an identifier in a block param
(block_params (identifier) @variable)
; As are helper arguments
((helper_invocation argument: [
(path_expression (identifier) @variable)
(identifier) @variable
])
(#not-match? @variable "this"))
; `this` should be highlighted as a built-in variable
((identifier) @variable.builtin
(#match? @variable.builtin "this"))
; If the identifier is just "yield" or "outlet", it's a keyword
((mustache_statement (identifier) @keyword)
(#match? @keyword "yield|outlet"))
; Helpers are functions
((helper_invocation helper: [
(path_expression (identifier) @function)
(identifier) @function
])
(#not-match? @function "if|yield"))
((helper_invocation helper: (identifier) @conditional)
(#match? @conditional "if"))
((helper_invocation helper: (identifier) @keyword)
(#match? @keyword "yield"))
(hash_pair key: (identifier) @property)
(comment_statement) @comment
(attribute_node "=" @operator)
(block_params "as" @keyword)
(block_params "|" @operator)
[
"<"
">"
"</"
"/>"
] @tag.delimiter

View File

@ -1,22 +0,0 @@
[
(element_node (element_node_start))
(element_node_void)
(block_statement (block_statement_start))
(mustache_statement)
] @indent.begin
(element_node (element_node_end [">"] @indent.end))
(element_node_void "/>" @indent.end)
[
">"
"/>"
"</"
"{{/"
"}}"
] @indent.branch
(mustache_statement
(helper_invocation helper: (identifier) @_identifier (#lua-match? @_identifier "else"))
) @indent.branch
(mustache_statement ((identifier) @_identifier (#lua-match? @_identifier "else"))) @indent.branch
(comment_statement) @indent.ignore

View File

@ -0,0 +1,65 @@
; inherits: ecma
(glimmer_opening_tag) @tag.builtin
(glimmer_closing_tag) @tag.builtin
;
;
; Copied from the javascript queries
;
;
; Parameters
(formal_parameters
(identifier) @variable.parameter)
(formal_parameters
(rest_pattern
(identifier) @variable.parameter))
; ({ a }) => null
(formal_parameters
(object_pattern
(shorthand_property_identifier_pattern) @variable.parameter))
; ({ a = b }) => null
(formal_parameters
(object_pattern
(object_assignment_pattern
(shorthand_property_identifier_pattern) @variable.parameter)))
; ({ a: b }) => null
(formal_parameters
(object_pattern
(pair_pattern
value: (identifier) @variable.parameter)))
; ([ a ]) => null
(formal_parameters
(array_pattern
(identifier) @variable.parameter))
; ({ a } = { a }) => null
(formal_parameters
(assignment_pattern
(object_pattern
(shorthand_property_identifier_pattern) @variable.parameter)))
; ({ a = b } = { a }) => null
(formal_parameters
(assignment_pattern
(object_pattern
(object_assignment_pattern
(shorthand_property_identifier_pattern) @variable.parameter))))
; a => null
(arrow_function
parameter: (identifier) @variable.parameter)
; optional parameters
(formal_parameters
(assignment_pattern
left: (identifier) @variable.parameter))
; punctuation
(optional_chain) @punctuation.delimiter

View File

@ -0,0 +1,5 @@
; inherits: ecma
(glimmer_opening_tag) @indent.begin
(glimmer_closing_tag) @indent.end

View File

@ -0,0 +1,15 @@
; inherits: ecma
; Parse Ember/Glimmer/Handlebars/HTMLBars/etc. template literals
; e.g.: await render(hbs`<SomeComponent />`)
(call_expression
function: ((identifier) @_name
(#eq? @_name "hbs"))
arguments: ((template_string) @glimmer
(#offset! @glimmer 0 1 0 -1)))
; Ember Unified <template> syntax
; e.g.: <template><SomeComponent @arg={{double @value}} /></template>
((glimmer_template) @injection.content
(#set! injection.language "glimmer")
(#set! injection.include-children))

View File

@ -0,0 +1,3 @@
; inherits: javascript
; extends

View File

@ -0,0 +1,8 @@
; inherits: typescript
; extends
; Sub-language delimeters
(glimmer_opening_tag) @tag.builtin
(glimmer_closing_tag) @tag.builtin

View File

@ -0,0 +1,2 @@
(glimmer_opening_tag) @indent.begin
(glimmer_closing_tag) @indent.end

View File

@ -0,0 +1,22 @@
; inherits: typescript
; extends
;
;
; Glimmer injections are here
;
;
; Parse Ember/Glimmer/Handlebars/HTMLBars/etc. template literals
; e.g.: await render(hbs`<SomeComponent />`)
(call_expression
function: ((identifier) @_name
(#eq? @_name "hbs"))
arguments: ((template_string) @glimmer
(#offset! @glimmer 0 1 0 -1)))
; Ember Unified <template> syntax
; e.g.: <template><SomeComponent @arg={{double @value}} /></template>
((glimmer_template) @injection.content
(#set! injection.language "glimmer")
(#set! injection.include-children))

View File

@ -1,175 +0,0 @@
(import_declaration
"import" @structure.anchor
(import_spec_list
"(" @structure.open
")" @structure.close
)
)
(function_declaration
"func" @structure.anchor
body: (block
"{" @structure.open
"}" @structure.close
)
)
(function_declaration
(identifier) @structure.anchor
(parameter_list
"(" @structure.open
("," @structure.separator (_))*
")" @structure.close
)
)
(method_declaration
"func" @structure.anchor
body: (block
"{" @structure.open
"}" @structure.close
)
)
(call_expression
function: (_) @structure.anchor
(argument_list
"(" @structure.open
("," @structure.separator (_))*
","? @structure.separator
")" @structure.close
)
)
(composite_literal
type: (_) @structure.anchor
body: (literal_value
"{" @structure.open
("," @structure.separator (_)?)*
"}" @structure.close
)
)
(literal_value
"{" @structure.anchor
("," @structure.separator (_)?)*
"}" @structure.close
)
(if_statement
["if" "else"] @structure.anchor
(block
"{" @structure.open
"}" @structure.close
)
)
(if_statement
"else" @structure.anchor
(if_statement
"if"
(block
"{" @structure.open
"}" @structure.close
)
)
)
(expression_switch_statement
"switch" @structure.anchor
"{" @structure.open
"}" @structure.close
)
(expression_switch_statement
(expression_case
"case" @structure.anchor
":" @structure.open
)
.
[
(expression_case "case" @structure.limit)
(default_case "default" @structure.limit)
]
)
(expression_switch_statement
(default_case "default" @structure.anchor)
"}" @structure.limit
)
(type_switch_statement
"switch" @structure.anchor
"{" @structure.open
"}" @structure.close
)
(type_switch_statement
(type_case
"case" @structure.anchor
":" @structure.open
)
.
[
(type_case "case" @structure.limit)
(default_case "default" @structure.limit)
]
)
(select_statement
"select" @structure.anchor
"{" @structure.open
"}" @structure.close
)
(func_literal
"func" @structure.anchor
(block
"{" @structure.open
"}" @structure.close
)
)
(for_statement
"for" @structure.anchor
(block
"{" @structure.open
"}" @structure.close
)
)
(type_declaration
"type" @structure.anchor
(type_spec
(struct_type
(field_declaration_list
"{" @structure.open
"}" @structure.close
)
)
)
)
(struct_type
"struct" @structure.anchor
(field_declaration_list
"{" @structure.open
"}" @structure.close
)
)
(type_declaration
"type" @structure.anchor
(type_spec
(interface_type
"{" @structure.open
"}" @structure.close
)
)
)
(interface_type
"interface" @structure.anchor
"{" @structure.open
"}" @structure.close
)

View File

@ -0,0 +1,6 @@
[
(argument_list)
(closure)
(list)
(map)
] @fold

View File

@ -0,0 +1,5 @@
((comment) @injection.content
(#set! injection.language "comment"))
((groovy_doc) @injection.content
(#set! injection.language "comment"))

View File

@ -1,42 +1,28 @@
; Keywords
(scheme) @module
; Methods
(method) @function.method
; Headers
(header
name: (name) @constant)
name: (_) @constant)
; Variables
(variable_declaration
name: (identifier) @variable)
; Fields
(pair
name: (identifier) @variable.member)
; URL / Host
(host) @string.special.url
(path
(identifier) @string.special.url)
; Parameters
(query_param
(key) @variable.parameter)
; Operators
[
"="
"?"
"&"
"@"
"<"
] @operator
(comment
"=" @operator)
(variable_declaration
"=" @operator)
; keywords
(comment
"@" @keyword
name: (_) @keyword)
; Literals
(target_url) @string.special.url
(request
url: (_) @string.special.url)
(http_version) @constant
@ -44,23 +30,21 @@
(status_code) @number
(status_text) @string
(string) @string
(number) @number
(boolean) @boolean
; Punctuation
[
"{{"
"}}"
] @punctuation.bracket
":" @punctuation.delimiter
(header
":" @punctuation.delimiter)
; external JSON body
(external_body
file_path: (path) @string.special.path)
path: (_) @string.special.path)
; Comments
(comment) @comment @spell
[
(comment)
(request_separator)
] @comment @spell

View File

@ -9,9 +9,16 @@
((xml_body) @injection.content
(#set! injection.language "xml"))
((graphql_body) @injection.content
((graphql_data) @injection.content
(#set! injection.language "graphql"))
; Lua scripting
((script_variable) @injection.content
(#set! injection.language "lua"))
; Script (default to javascript)
((comment
name: (_) @_name
(#eq? @_name "lang")
value: (_) @injection.language)?
.
(_
(script) @injection.content
(#offset! @injection.content 0 2 0 -2))
(#set! injection.language "javascript"))

View File

@ -168,7 +168,7 @@
(preproc_call
directive: (preproc_directive) @keyword.directive
argument: (_) @constant)
argument: (_)? @constant)
(module_dcl
(identifier) @module)

View File

@ -0,0 +1,11 @@
# Guidelines for writing queries
- No highlighting is better than ambiguous highlighting.
If syntax highlighting is excessive or _wrong,_ it loses its value.
- Only public names defined in `Core` should be highlighted as `builtin`.
Julia `Base` is huge, and highlighting everything in it has diminishing returns.
- Captures mostly follow [Neovim's naming conventions](https://neovim.io/doc/user/treesitter.html#treesitter-highlight-groups),
since they're well documented and widely used.
Adapting the captures to work with other editors usually requires a few small changes.

View File

@ -0,0 +1,332 @@
; Identifiers
(identifier) @variable
(field_expression
(identifier) @variable.member .)
; Symbols
(quote_expression
":" @string.special.symbol
[
(identifier)
(operator)
] @string.special.symbol)
; Function calls
(call_expression
(identifier) @function.call)
(call_expression
(field_expression
(identifier) @function.call .))
(broadcast_call_expression
(identifier) @function.call)
(broadcast_call_expression
(field_expression
(identifier) @function.call .))
; Macros
(macro_identifier) @function.macro
(macro_definition
(signature
(call_expression
.
(identifier) @function.macro)))
; Built-in functions
; filter(name -> Base.eval(Core, name) isa Core.Builtin, names(Core))
((identifier) @function.builtin
(#any-of? @function.builtin
"applicable" "fieldtype" "getfield" "getglobal" "invoke" "isa" "isdefined" "modifyfield!"
"modifyglobal!" "nfields" "replacefield!" "replaceglobal!" "setfield!" "setfieldonce!"
"setglobal!" "setglobalonce!" "swapfield!" "swapglobal!" "throw" "tuple" "typeassert" "typeof"))
; Type definitions
(abstract_definition
name: (identifier) @type.definition) @keyword
(primitive_definition
name: (identifier) @type.definition) @keyword
(struct_definition
name: (identifier) @type.definition)
(type_clause
[
(identifier) @type
(field_expression
(identifier) @type .)
])
; Type annotations
(parametrized_type_expression
[
(identifier) @type
(field_expression
(identifier) @type .)
]
(curly_expression
(_) @type))
(type_parameter_list
(identifier) @type)
(typed_expression
(identifier) @type .)
(unary_typed_expression
(identifier) @type .)
(where_clause
(identifier) @type)
(where_clause
(curly_expression
(_) @type))
; Built-in types
; filter(name -> typeof(Base.eval(Core, name)) in [DataType, UnionAll], names(Core))
((identifier) @type.builtin
(#any-of? @type.builtin
"AbstractArray" "AbstractChar" "AbstractFloat" "AbstractString" "Any" "ArgumentError" "Array"
"AssertionError" "Bool" "BoundsError" "Char" "ConcurrencyViolationError" "Cvoid" "DataType"
"DenseArray" "DivideError" "DomainError" "ErrorException" "Exception" "Expr" "Float16" "Float32"
"Float64" "Function" "GlobalRef" "IO" "InexactError" "InitError" "Int" "Int128" "Int16" "Int32"
"Int64" "Int8" "Integer" "InterruptException" "LineNumberNode" "LoadError" "Method"
"MethodError" "Module" "NTuple" "NamedTuple" "Nothing" "Number" "OutOfMemoryError"
"OverflowError" "Pair" "Ptr" "QuoteNode" "ReadOnlyMemoryError" "Real" "Ref" "SegmentationFault"
"Signed" "StackOverflowError" "String" "Symbol" "Task" "Tuple" "Type" "TypeError" "TypeVar"
"UInt" "UInt128" "UInt16" "UInt32" "UInt64" "UInt8" "UndefInitializer" "UndefKeywordError"
"UndefRefError" "UndefVarError" "Union" "UnionAll" "Unsigned" "VecElement" "WeakRef"))
; Keywords
[
"const"
"global"
"local"
] @keyword
(compound_statement
[
"begin"
"end"
] @keyword)
(quote_statement
[
"quote"
"end"
] @keyword)
(let_statement
[
"let"
"end"
] @keyword)
(if_statement
[
"if"
"end"
] @keyword.conditional)
(elseif_clause
"elseif" @keyword.conditional)
(else_clause
"else" @keyword.conditional)
(ternary_expression
[
"?"
":"
] @keyword.conditional.ternary)
(try_statement
[
"try"
"end"
] @keyword.exception)
(catch_clause
"catch" @keyword.exception)
(finally_clause
"finally" @keyword.exception)
(for_statement
[
"for"
"end"
] @keyword.repeat)
(for_binding
"outer" @keyword.repeat)
; comprehensions
(for_clause
"for" @keyword.repeat)
(if_clause
"if" @keyword.conditional)
(while_statement
[
"while"
"end"
] @keyword.repeat)
[
(break_statement)
(continue_statement)
] @keyword.repeat
(function_definition
[
"function"
"end"
] @keyword.function)
(do_clause
[
"do"
"end"
] @keyword.function)
(macro_definition
[
"macro"
"end"
] @keyword)
(return_statement
"return" @keyword.return)
(module_definition
[
"module"
"baremodule"
"end"
] @keyword.import)
(export_statement
"export" @keyword.import)
(import_statement
[
"import"
"using"
] @keyword.import)
(import_alias
"as" @keyword.import)
(selected_import
":" @punctuation.delimiter)
(struct_definition
[
"mutable"
"struct"
"end"
] @keyword.type)
; Operators & Punctuation
[
"->"
"="
"∈"
(operator)
] @operator
(adjoint_expression
"'" @operator)
(range_expression
":" @operator)
[
"."
"..."
"::"
] @punctuation.special
[
","
";"
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
; Keyword operators
((operator) @keyword.operator
(#any-of? @keyword.operator "in" "isa"))
(for_binding
"in" @keyword.operator)
(where_clause
"where" @keyword.operator)
(where_expression
"where" @keyword.operator)
; Built-in constants
((identifier) @constant.builtin
(#any-of? @constant.builtin "nothing" "missing"))
((identifier) @variable.builtin
(#any-of? @variable.builtin "begin" "end")
(#has-ancestor? @variable.builtin index_expression))
; Literals
(boolean_literal) @boolean
(integer_literal) @number
(float_literal) @number.float
((identifier) @number.float
(#any-of? @number.float "NaN" "NaN16" "NaN32" "Inf" "Inf16" "Inf32"))
(character_literal) @character
(escape_sequence) @string.escape
(string_literal) @string
(prefixed_string_literal
prefix: (identifier) @function.macro) @string
(command_literal) @string.special
(prefixed_command_literal
prefix: (identifier) @function.macro) @string.special
((string_literal) @string.documentation
.
[
(abstract_definition)
(assignment)
(const_statement)
(function_definition)
(macro_definition)
(module_definition)
(struct_definition)
])
[
(line_comment)
(block_comment)
] @comment

View File

@ -205,7 +205,7 @@
] @number
[
"null" ; should be highlighted the same as booleans
(null_literal) ; should be highlighted the same as booleans
(boolean_literal)
] @boolean

View File

@ -1,146 +1,165 @@
(variable_identifier) @variable
(constant_identifier) @constant
[
"assert"
"assert_eq"
"assert_neq"
"block"
"console"
"const"
"let"
"mapping"
"program"
"record"
"self"
"struct"
"then"
"assert"
"assert_eq"
"assert_neq"
"block"
"console"
"const"
"let"
"mapping"
"program"
"self"
"then"
] @keyword
"in" @keyword.operator
[
"record"
"struct"
] @keyword.type
"in" @keyword.operator
[
"constant"
"private"
"public"
] @type.qualifier
"constant"
"private"
"public"
] @keyword.modifier
"self" @variable.builtin
"network" @variable.builtin
"async" @keyword.coroutine
[
"finalize"
"function"
"inline"
"transition"
"finalize"
"function"
"inline"
"transition"
] @keyword.function
"import" @include
"import" @keyword.import
"return" @keyword.return
(return_arrow) @punctuation.delimiter
"for" @repeat
"for" @keyword.repeat
[
[
"else"
"if"
] @conditional
] @keyword.conditional
[
(ternary_if)
(ternary_else)
] @conditional.ternary
[ "(" ")" "{" "}" "[" "]" ] @punctuation.bracket
[ ";" "," "::"] @punctuation.delimiter
(ternary_if)
(ternary_else)
] @keyword.conditional.ternary
[
"!"
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
"&&"
"||"
"=="
"!="
"<"
"<="
">"
">="
"&"
"|"
"^"
"<<"
">>"
"+"
"-"
"*"
"/"
"%"
"**"
"="
"+="
"-="
"*="
"/="
"%="
"**="
"<<="
">>="
"&="
"|="
"^="
"&&="
"||="
[
";"
","
"::"
] @punctuation.delimiter
[
"!"
"&&"
"||"
"=="
"!="
"<"
"<="
">"
">="
"&"
"|"
"^"
"<<"
">>"
"+"
"-"
"*"
"/"
"%"
"**"
"="
"+="
"-="
"*="
"/="
"%="
"**="
"<<="
">>="
"&="
"|="
"^="
"&&="
"||="
] @operator
(comment) @comment @spell
(boolean_literal) @boolean
(constant_declaration
(identifier) @constant)
(constant_declaration
(identifier
(constant_identifier) @constant))
[
(program_id)
(this_program_id)
] @string.special
;record declaration
(record_declaration (identifier) @field)
;struct component
(struct_component_declaration
(identifier) @field)
(type) @type
(variable
(constant_identifier) @constant)
(associated_constant) @constant
(variable) @variable
[
(block_height)
(self_caller)
(self_signer)
(program_id)
] @string.special
;record declaration
(record_declaration
(identifier) @type.definition)
;struct component
(struct_component_declaration
(identifier) @variable.member)
(type) @type
[
(block_height)
(self_address)
(self_caller)
(self_signer)
(network_id)
] @constant.builtin
(free_function_call
(locator
(identifier) @function))
(locator
(identifier) @function))
(associated_function_call
(named_type
(identifier
(constant_identifier) @function)))
(associated_function_call
(identifier) @function.call)
(record_type
(locator
(identifier) @field))
(locator
(identifier) @variable.member))
(transition_declaration
name: (identifier) @function.builtin)
@ -158,28 +177,32 @@
name: (identifier) @function.macro)
(method_call
. (_)
. (identifier) @method.call)
.
(_)
.
(identifier) @function.method.call)
(function_parameter
(identifier) @parameter)
(identifier) @variable.parameter)
(struct_declaration
name: (identifier) @field)
name: (identifier) @type.definition)
(variable_declaration
(identifier_or_identifiers
(identifier) @variable))
(identifier) @variable)
[
[
(address_literal)
(signature_literal)
((affine_group_literal) (#set! "priority" 101))
(field_literal)
(product_group_literal)
(scalar_literal)
(signed_literal)
(unsigned_literal)
((affine_group_literal)
(#set! priority 101))
(field_literal)
(product_group_literal)
(scalar_literal)
(signed_literal)
(unsigned_literal)
] @number
(string_literal) @string
(annotation) @attribute

View File

@ -7,7 +7,7 @@
"%}"
"{%-"
"-%}"
] @tag.delimiter
] @tag.delimiter
(#set! priority 101))
@ -16,13 +16,13 @@
"["
")"
"("
] @punctuation.bracket
] @punctuation.bracket
(#set! priority 101))
([
","
"."
] @punctuation.delimiter
] @punctuation.delimiter
(#set! priority 101))
@ -34,6 +34,7 @@
"capture"
"case"
(continue_statement)
(custom_unpaired_statement)
"cycle"
"decrement"
"echo"
@ -55,6 +56,7 @@
"form"
"if"
"include"
"include_relative"
"increment"
"javascript"
"layout"
@ -70,7 +72,7 @@
"unless"
"when"
"with"
] @keyword
] @keyword
(#set! priority 101))
([
@ -86,7 +88,7 @@
":"
"="
(predicate)
] @operator
] @operator
(#set! priority 101))
((identifier) @variable (#set! priority 101))

View File

@ -1,99 +0,0 @@
(comment) @comment
[
"if"
"then"
"else"
"let"
"inherit"
"in"
"rec"
"with"
"assert"
"or"
] @keyword
((identifier) @variable.builtin
(#match? @variable.builtin "^(__currentSystem|__currentTime|__nixPath|__nixVersion|__storeDir|builtins|false|null|true)$")
(#is-not? local))
((identifier) @function.builtin
(#match? @function.builtin "^(__add|__addErrorContext|__all|__any|__appendContext|__attrNames|__attrValues|__bitAnd|__bitOr|__bitXor|__catAttrs|__compareVersions|__concatLists|__concatMap|__concatStringsSep|__deepSeq|__div|__elem|__elemAt|__fetchurl|__filter|__filterSource|__findFile|__foldl'|__fromJSON|__functionArgs|__genList|__genericClosure|__getAttr|__getContext|__getEnv|__hasAttr|__hasContext|__hashFile|__hashString|__head|__intersectAttrs|__isAttrs|__isBool|__isFloat|__isFunction|__isInt|__isList|__isPath|__isString|__langVersion|__length|__lessThan|__listToAttrs|__mapAttrs|__match|__mul|__parseDrvName|__partition|__path|__pathExists|__readDir|__readFile|__replaceStrings|__seq|__sort|__split|__splitVersion|__storePath|__stringLength|__sub|__substring|__tail|__toFile|__toJSON|__toPath|__toXML|__trace|__tryEval|__typeOf|__unsafeDiscardOutputDependency|__unsafeDiscardStringContext|__unsafeGetAttrPos|__valueSize|abort|baseNameOf|derivation|derivationStrict|dirOf|fetchGit|fetchMercurial|fetchTarball|fromTOML|import|isNull|map|placeholder|removeAttrs|scopedImport|throw|toString)$")
(#is-not? local))
[
(integer_expression)
(float_expression)
] @number
(escape_sequence) @escape
(dollar_escape) @escape
(function_expression
universal: (identifier) @variable.parameter
)
(formal
name: (identifier) @variable.parameter
"?"? @punctuation.delimiter)
(select_expression
attrpath: (attrpath (identifier)) @property)
(apply_expression
function: [
(variable_expression (identifier)) @function
(select_expression
attrpath: (attrpath
attr: (identifier) @function .))])
(unary_expression
operator: _ @operator)
(binary_expression
operator: _ @operator)
(variable_expression (identifier) @variable)
(binding
attrpath: (attrpath (identifier)) @property)
(identifier) @property
(inherit_from attrs: (inherited_attrs attr: (identifier) @property) )
[
";"
"."
","
"="
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
(identifier) @variable
[
(string_expression)
(indented_string_expression)
] @string
[
(path_expression)
(hpath_expression)
(spath_expression)
] @string.special.path
(uri_expression) @string.special.uri
(interpolation
"${" @punctuation.special
(_) @embedded
"}" @punctuation.special)

View File

@ -29,9 +29,11 @@
(kNodefault)
(kStored)
(kIndex)
(kDispId)
(kClass)
(kInterface)
(kDispInterface)
(kObject)
(kRecord)
(kObjcclass)

View File

@ -36,7 +36,7 @@
"\\" @operator
[
"or" "and"
"or" "xor" "and"
"eq" "ne" "cmp" "lt" "le" "ge" "gt"
"isa"
] @keyword.operator

View File

@ -0,0 +1,30 @@
(conditional_statement
["if" "unless"] @open.if
"elsif"? @mid.if.1
"else"? @mid.if.2
(block "}" @close.if) .
) @scope.if
(conditional_expression
"?" @open.ternary
":" @mid.ternary.1
) @scope.ternary
(_
["for" "foreach" "while" "unless"] @open.loop
(block "}" @close.loop) .
) @scope.loop
(loopex_expression) @mid.loop.1
(_
"sub" @open.fun
(block "}" @close.fun) .
) @scope.fun
(return_expression "return" @mid.fun.1)
(_
[
("'" @open.quotelike "'" @close.quotelike)
("'" @open.quotelike (_) "'"+ @mid.quotelike.1 (replacement) "'" @close.quotelike)
]
) @scope.quotelike

View File

@ -96,6 +96,8 @@
"is"
"not"
"or"
"is not"
"not in"
] @operator
[

View File

@ -0,0 +1,30 @@
; These indent queries adhere to nvim-tree-sytter syntax.
; See `nvim-tree-sitter-indentation-mod` vim help page.
[
(template_body)
(block)
(parameters)
(arguments)
(match_expression)
(splice_expression)
(import_declaration)
(function_definition)
(ERROR ":")
(ERROR "=")
("match")
(":")
("=")
] @indent.begin
(arguments ")" @indent.end)
"}" @indent.end
"end" @indent.end
[
")"
"]"
"}"
] @indent.branch

View File

@ -0,0 +1,23 @@
;; highlights.scm
(number) @number
(identifier) @variable
(version) @number.readonly
(namespace) @namespace
(limit) @property
(limit (identifier) @string)
(limit (number) @number)
(duration (number) @number.readonly) @string
(location (number) @number.readonly) @string
(event_detail (event_detail_value) @string)
(log_level_settings) @comment
(log_level_setting (component) @type)
(log_level_setting (log_level) @constant)
(log_entry (timestamp (time) @function) @number)
(log_entry (location) @number)
(log_entry (event_identifier (identifier) @type) @keyword)

View File

@ -13,7 +13,7 @@
name: _ @keyword))
; Subordinate directives (eg. input, output)
(_
((_)
body: (_
(directive
name: _ @label)))
@ -33,6 +33,7 @@
"use" @keyword.import
"rule" @keyword.import
"from" @keyword.import
"exclude"? @keyword.import
"as"? @keyword.import
"with"? @keyword.import)
@ -43,9 +44,8 @@
"with" @keyword)
; Wildcard names
(wildcard
(identifier) @variable
(flag) @variable.parameter.builtin)
(wildcard (identifier) @variable)
(wildcard (flag) @variable.parameter.builtin)
; builtin variables
((identifier) @variable.builtin

View File

@ -1,13 +1,22 @@
; inherits: python
((rule_definition) @indent.begin
(#set! indent.immediate 1))
(#set! indent.immediate 1))
((checkpoint_definition) @indent.begin
(#set! indent.immediate 1))
(#set! indent.immediate 1))
((rule_inheritance) @indent.begin
(#set! indent.immediate 1))
(#set! indent.immediate 1))
((rule_import "with" ":") @indent.begin
(#set! indent.immediate 1))
((module_definition) @indent.begin
(#set! indent.immediate 1))
(#set! indent.immediate 1))
((directive) @indent.begin
(#set! indent.immediate 1))
(#set! indent.immediate 1))
; end indentation after last parameter node (no following ',')
(directive_parameters (_)* (_) @indent.end)

View File

@ -0,0 +1,66 @@
(protocol_declaration
declaration_kind: "protocol" @name
.
_ * @name
.
body: (protocol_body)
) @item
(class_declaration
declaration_kind: (
[
"actor"
"class"
"extension"
"enum"
"struct"
]
) @name
.
_ * @name
.
body: (_)
) @item
(init_declaration
name: "init" @name
.
_ * @name
.
body: (function_body)
) @item
(deinit_declaration
"deinit" @name) @item
(function_declaration
"func" @name
.
_ * @name
.
body: (function_body)
) @item
(class_body
(property_declaration
(value_binding_pattern) @name
name: (pattern) @name
(type_annotation)? @name
) @item
)
(enum_class_body
(property_declaration
(value_binding_pattern) @name
name: (pattern) @name
(type_annotation)? @name
) @item
)
(
(protocol_function_declaration) @name
) @item
(
(protocol_property_declaration) @name
) @item

View File

@ -135,8 +135,6 @@
(instance_argument
name: (identifier) @property)
(lvalue (_) (_) @property)
(field_access_expression
name: (identifier) @property)

View File

@ -42,4 +42,5 @@
(value_expression (identifier) @local.reference)
(lvalue (identifier) @local.reference)
(field_access_expression
name: (identifier) @local.reference)

View File

@ -7,7 +7,7 @@
(while_statement)
(if_statement)
(if_let_statement)
(elif_block)
(else_if_block)
(struct_definition)
(enum_definition)
(try_catch_statement)

View File

@ -82,7 +82,7 @@
"class"
"let"
"new"
(inflight_specifier)
(phase_specifier)
] @keyword
[

View File

@ -1,16 +1,23 @@
[
(Block)
(ContainerDecl)
(SwitchExpr)
(InitList)
(AsmExpr)
(ErrorSetDecl)
(LINESTRING)
(
[
(IfPrefix)
(WhilePrefix)
(ForPrefix)
]
)
(block)
(switch_expression)
(initializer_list)
(asm_expression)
(multiline_string)
(if_statement)
(while_statement)
(for_statement)
(if_expression)
(else_clause)
(for_expression)
(while_expression)
(if_type_expression)
(function_signature)
(parameters)
(struct_declaration)
(opaque_declaration)
(enum_declaration)
(union_declaration)
(error_set_declaration)
] @fold

View File

@ -1,112 +1,132 @@
[
(container_doc_comment)
(doc_comment)
(line_comment)
] @comment @spell
; Variables
[
variable: (IDENTIFIER)
variable_type_function: (IDENTIFIER)
] @variable
(identifier) @variable
parameter: (IDENTIFIER) @parameter
; Parameters
[
field_member: (IDENTIFIER)
field_access: (IDENTIFIER)
] @field
(parameter
name: (identifier) @variable.parameter)
;; assume TitleCase is a type
(
; Types
(parameter
type: (identifier) @type)
((identifier) @type
(#lua-match? @type "^[A-Z_][a-zA-Z0-9_]*"))
(variable_declaration
(identifier) @type
"="
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
parameter: (IDENTIFIER)
] @type
(#match? @type "^[A-Z]([a-z]+[A-Za-z0-9]*)*$")
)
;; assume camelCase is a function
(
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
parameter: (IDENTIFIER)
] @function
(#match? @function "^[a-z]+([A-Z][a-z0-9]*)+$")
)
;; assume all CAPS_1 is a constant
(
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
] @constant
(#match? @constant "^[A-Z][A-Z_0-9]+$")
)
(struct_declaration)
(enum_declaration)
(union_declaration)
(opaque_declaration)
])
[
function_call: (IDENTIFIER)
function: (IDENTIFIER)
] @function
(builtin_type)
"anyframe"
] @type.builtin
exception: "!" @exception
; Constants
(
(IDENTIFIER) @variable.builtin
(#eq? @variable.builtin "_")
)
(PtrTypeStart "c" @variable.builtin)
(
(ContainerDeclType
[
(ErrorUnionExpr)
"enum"
]
)
(ContainerField (IDENTIFIER) @constant)
)
field_constant: (IDENTIFIER) @constant
(BUILTINIDENTIFIER) @function.builtin
((BUILTINIDENTIFIER) @include
(#any-of? @include "@import" "@cImport"))
(INTEGER) @number
(FLOAT) @float
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]+$"))
[
"true"
"false"
] @boolean
"null"
"unreachable"
"undefined"
] @constant.builtin
(field_expression
.
member: (identifier) @constant)
(enum_declaration
(container_field
type: (identifier) @constant))
; Labels
(block_label (identifier) @label)
(break_label (identifier) @label)
; Fields
(field_initializer
.
(identifier) @variable.member)
(field_expression
(_)
member: (identifier) @variable.member)
(container_field
name: (identifier) @variable.member)
(initializer_list
(assignment_expression
left: (field_expression
.
member: (identifier) @variable.member)))
; Functions
(builtin_identifier) @function.builtin
(call_expression
function: (identifier) @function.call)
(call_expression
function: (field_expression
member: (identifier) @function.call))
(function_declaration
name: (identifier) @function)
; Modules
(variable_declaration
(identifier) @module
(builtin_function
(builtin_identifier) @keyword.import
(#any-of? @keyword.import "@import" "@cImport")))
; Builtins
[
(LINESTRING)
(STRINGLITERALSINGLE)
] @string @spell
"c"
"..."
] @variable.builtin
(CHAR_LITERAL) @character
(EscapeSequence) @string.escape
(FormatSequence) @string.special
((identifier) @variable.builtin
(#eq? @variable.builtin "_"))
(BreakLabel (IDENTIFIER) @label)
(BlockLabel (IDENTIFIER) @label)
(calling_convention
(identifier) @variable.builtin)
; Keywords
[
"asm"
"defer"
"errdefer"
"test"
"error"
"const"
"var"
] @keyword
[
"struct"
"union"
"enum"
"opaque"
"error"
] @keyword
] @keyword.type
[
"async"
@ -116,9 +136,7 @@ field_constant: (IDENTIFIER) @constant
"resume"
] @keyword.coroutine
[
"fn"
] @keyword.function
"fn" @keyword.function
[
"and"
@ -126,96 +144,124 @@ field_constant: (IDENTIFIER) @constant
"orelse"
] @keyword.operator
[
"return"
] @keyword.return
"return" @keyword.return
[
"if"
"else"
"switch"
] @conditional
] @keyword.conditional
[
"for"
"while"
"break"
"continue"
] @repeat
] @keyword.repeat
[
"usingnamespace"
] @include
"export"
] @keyword.import
[
"try"
"catch"
] @exception
] @keyword.exception
[
"anytype"
(BuildinTypeExpr)
] @type.builtin
[
"const"
"var"
"volatile"
"allowzero"
"noalias"
] @type.qualifier
[
"addrspace"
"align"
"callconv"
"linksection"
] @storageclass
[
"comptime"
"export"
"extern"
"pub"
"inline"
"noinline"
"extern"
"comptime"
"packed"
"pub"
"threadlocal"
] @attribute
] @keyword.modifier
; Operator
[
"null"
"unreachable"
"undefined"
] @constant.builtin
[
(CompareOp)
(BitwiseOp)
(BitShiftOp)
(AdditionOp)
(AssignOp)
(MultiplyOp)
(PrefixOp)
"="
"*="
"*%="
"*|="
"/="
"%="
"+="
"+%="
"+|="
"-="
"-%="
"-|="
"<<="
"<<|="
">>="
"&="
"^="
"|="
"!"
"~"
"-"
"-%"
"&"
"=="
"!="
">"
">="
"<="
"<"
"&"
"^"
"|"
"<<"
">>"
"<<|"
"+"
"++"
"+%"
"-%"
"+|"
"-|"
"*"
"/"
"%"
"**"
"->"
".?"
"*%"
"*|"
"||"
".*"
".?"
"?"
".."
] @operator
[
";"
"."
","
":"
] @punctuation.delimiter
; Literals
[
".."
"..."
] @punctuation.special
(character) @character
([
(string)
(multiline_string)
] @string
(#set! "priority" 95))
(integer) @number
(float) @number.float
(boolean) @boolean
(escape_sequence) @string.escape
; Punctuation
[
"["
@ -224,10 +270,22 @@ field_constant: (IDENTIFIER) @constant
")"
"{"
"}"
(Payload "|")
(PtrPayload "|")
(PtrIndexPayload "|")
] @punctuation.bracket
; Error
(ERROR) @error
[
";"
"."
","
":"
"=>"
"->"
] @punctuation.delimiter
(payload "|" @punctuation.bracket)
; Comments
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^//!"))

View File

@ -1,9 +1,11 @@
[
(Block)
(ContainerDecl)
(SwitchExpr)
(InitList)
] @indent
(block)
(switch_expression)
(initializer_list)
] @indent.begin
(block
"}" @indent.end)
[
"("
@ -12,11 +14,9 @@
"]"
"{"
"}"
] @branch
] @indent.branch
[
(line_comment)
(container_doc_comment)
(doc_comment)
(LINESTRING)
] @ignore
(comment)
(multiline_string)
] @indent.ignore

View File

@ -1,5 +1,10 @@
[
(container_doc_comment)
(doc_comment)
(line_comment)
] @comment
((comment) @injection.content
(#set! injection.language "comment"))
; TODO: add when asm is added
; (asm_output_item (string) @injection.content
; (#set! injection.language "asm"))
; (asm_input_item (string) @injection.content
; (#set! injection.language "asm"))
; (asm_clobbers (string) @injection.content
; (#set! injection.language "asm"))