chore: query formatting

This commit is contained in:
Pham Huy Hoang 2024-01-06 15:05:50 +09:00 committed by Christian Clason
parent 79975d6557
commit 57a8acf0c4
674 changed files with 18466 additions and 12648 deletions

View file

@ -1,14 +1,13 @@
;; Support for folding in Ada ; Support for folding in Ada
;; za toggles folding a package, subprogram, if statement or loop ; za toggles folding a package, subprogram, if statement or loop
[ [
(package_declaration) (package_declaration)
(generic_package_declaration) (generic_package_declaration)
(package_body) (package_body)
(subprogram_body) (subprogram_body)
(block_statement) (block_statement)
(if_statement) (if_statement)
(loop_statement) (loop_statement)
(gnatprep_declarative_if_statement) (gnatprep_declarative_if_statement)
(gnatprep_if_statement) (gnatprep_if_statement)
] @fold ] @fold

View file

@ -1,190 +1,288 @@
;; highlight queries. ; highlight queries.
;; See the syntax at https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries ; See the syntax at https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries
;; See also https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations ; See also https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations
;; for a list of recommended @ tags, though not all of them have matching ; for a list of recommended @ tags, though not all of them have matching
;; highlights in neovim. ; highlights in neovim.
[
"abort"
"abs"
"abstract"
"accept"
"access"
"all"
"array"
"at"
"begin"
"declare"
"delay"
"delta"
"digits"
"do"
"end"
"entry"
"exit"
"generic"
"interface"
"is"
"limited"
"null"
"of"
"others"
"out"
"pragma"
"private"
"range"
"synchronized"
"tagged"
"task"
"terminate"
"until"
"when"
] @keyword
[ [
"abort" "aliased"
"abs" "constant"
"abstract" "renames"
"accept"
"access"
"all"
"array"
"at"
"begin"
"declare"
"delay"
"delta"
"digits"
"do"
"end"
"entry"
"exit"
"generic"
"interface"
"is"
"limited"
"null"
"of"
"others"
"out"
"pragma"
"private"
"range"
"synchronized"
"tagged"
"task"
"terminate"
"until"
"when"
] @keyword
[
"aliased"
"constant"
"renames"
] @keyword.storage ] @keyword.storage
[ [
"mod" "mod"
"new" "new"
"protected" "protected"
"record" "record"
"subtype" "subtype"
"type" "type"
] @keyword.type ] @keyword.type
[ [
"with" "with"
"use" "use"
] @keyword.import ] @keyword.import
[ [
"body" "body"
"function" "function"
"overriding" "overriding"
"procedure" "procedure"
"package" "package"
"separate" "separate"
] @keyword.function ] @keyword.function
[ [
"and" "and"
"in" "in"
"not" "not"
"or" "or"
"xor" "xor"
] @keyword.operator ] @keyword.operator
[ [
"while" "while"
"loop" "loop"
"for" "for"
"parallel" "parallel"
"reverse" "reverse"
"some" "some"
] @keyword.repeat ] @keyword.repeat
"return" @keyword.return
[ [
"return" "case"
] @keyword.return "if"
[ "else"
"case" "then"
"if" "elsif"
"else" "select"
"then"
"elsif"
"select"
] @keyword.conditional ] @keyword.conditional
[ [
"exception" "exception"
"raise" "raise"
] @keyword.exception ] @keyword.exception
(comment) @comment @spell (comment) @comment @spell
(string_literal) @string (string_literal) @string
(character_literal) @string (character_literal) @string
(numeric_literal) @number (numeric_literal) @number
;; Highlight the name of subprograms ; Highlight the name of subprograms
(procedure_specification name: (_) @function) (procedure_specification
(function_specification name: (_) @function) name: (_) @function)
(package_declaration name: (_) @function)
(package_body name: (_) @function)
(generic_instantiation name: (_) @function)
(entry_declaration . (identifier) @function)
;; Some keywords should take different categories depending on the context (function_specification
(use_clause "use" @keyword.import "type" @keyword.import) name: (_) @function)
(with_clause "private" @keyword.import)
(with_clause "limited" @keyword.import)
(use_clause (_) @module)
(with_clause (_) @module)
(loop_statement "end" @keyword.repeat) (package_declaration
(if_statement "end" @keyword.conditional) name: (_) @function)
(loop_parameter_specification "in" @keyword.repeat)
(loop_parameter_specification "in" @keyword.repeat)
(iterator_specification ["in" "of"] @keyword.repeat)
(range_attribute_designator "range" @keyword.repeat)
(raise_statement "with" @keyword.exception) (package_body
name: (_) @function)
(gnatprep_declarative_if_statement) @keyword.directive (generic_instantiation
(gnatprep_if_statement) @keyword.directive name: (_) @function)
(gnatprep_identifier) @keyword.directive
(subprogram_declaration "is" @keyword.function "abstract" @keyword.function) (entry_declaration
(aspect_specification "with" @keyword.function) .
(identifier) @function)
(full_type_declaration "is" @keyword.type) ; Some keywords should take different categories depending on the context
(subtype_declaration "is" @keyword.type) (use_clause
(record_definition "end" @keyword.type) "use" @keyword.import
(full_type_declaration (_ "access" @keyword.type)) "type" @keyword.import)
(array_type_definition "array" @keyword.type "of" @keyword.type)
(access_to_object_definition "access" @keyword.type)
(access_to_object_definition "access" @keyword.type
[
(general_access_modifier "constant" @keyword.type)
(general_access_modifier "all" @keyword.type)
]
)
(range_constraint "range" @keyword.type)
(signed_integer_type_definition "range" @keyword.type)
(index_subtype_definition "range" @keyword.type)
(record_type_definition "abstract" @keyword.type)
(record_type_definition "tagged" @keyword.type)
(record_type_definition "limited" @keyword.type)
(record_type_definition (record_definition "null" @keyword.type))
(private_type_declaration "is" @keyword.type "private" @keyword.type)
(private_type_declaration "tagged" @keyword.type)
(private_type_declaration "limited" @keyword.type)
(task_type_declaration "task" @keyword.type "is" @keyword.type)
;; Gray the body of expression functions (with_clause
"private" @keyword.import)
(with_clause
"limited" @keyword.import)
(use_clause
(_) @module)
(with_clause
(_) @module)
(loop_statement
"end" @keyword.repeat)
(if_statement
"end" @keyword.conditional)
(loop_parameter_specification
"in" @keyword.repeat)
(loop_parameter_specification
"in" @keyword.repeat)
(iterator_specification
[
"in"
"of"
] @keyword.repeat)
(range_attribute_designator
"range" @keyword.repeat)
(raise_statement
"with" @keyword.exception)
(gnatprep_declarative_if_statement) @keyword.directive
(gnatprep_if_statement) @keyword.directive
(gnatprep_identifier) @keyword.directive
(subprogram_declaration
"is" @keyword.function
"abstract" @keyword.function)
(aspect_specification
"with" @keyword.function)
(full_type_declaration
"is" @keyword.type)
(subtype_declaration
"is" @keyword.type)
(record_definition
"end" @keyword.type)
(full_type_declaration
(_
"access" @keyword.type))
(array_type_definition
"array" @keyword.type
"of" @keyword.type)
(access_to_object_definition
"access" @keyword.type)
(access_to_object_definition
"access" @keyword.type
[
(general_access_modifier
"constant" @keyword.type)
(general_access_modifier
"all" @keyword.type)
])
(range_constraint
"range" @keyword.type)
(signed_integer_type_definition
"range" @keyword.type)
(index_subtype_definition
"range" @keyword.type)
(record_type_definition
"abstract" @keyword.type)
(record_type_definition
"tagged" @keyword.type)
(record_type_definition
"limited" @keyword.type)
(record_type_definition
(record_definition
"null" @keyword.type))
(private_type_declaration
"is" @keyword.type
"private" @keyword.type)
(private_type_declaration
"tagged" @keyword.type)
(private_type_declaration
"limited" @keyword.type)
(task_type_declaration
"task" @keyword.type
"is" @keyword.type)
; Gray the body of expression functions
(expression_function_declaration (expression_function_declaration
(function_specification) (function_specification)
"is" "is"
(_) @attribute (_) @attribute)
)
(subprogram_declaration (aspect_specification) @attribute)
;; Highlight full subprogram specifications (subprogram_declaration
(aspect_specification) @attribute)
; Highlight full subprogram specifications
;(subprogram_body ;(subprogram_body
; [ ; [
; (procedure_specification) ; (procedure_specification)
; (function_specification) ; (function_specification)
; ] @function.spec ; ] @function.spec
;) ;)
((comment) @comment.documentation ((comment) @comment.documentation
. [ .
(entry_declaration) [
(subprogram_declaration) (entry_declaration)
(parameter_specification) (subprogram_declaration)
]) (parameter_specification)
])
(compilation_unit (compilation_unit
. (comment) @comment.documentation) .
(comment) @comment.documentation)
(component_list (component_list
(component_declaration) (component_declaration)
. (comment) @comment.documentation) .
(comment) @comment.documentation)
(enumeration_type_definition (enumeration_type_definition
(identifier) (identifier)
. (comment) @comment.documentation) .
(comment) @comment.documentation)

View file

@ -1,33 +1,91 @@
;; Better highlighting by referencing to the definition, for variable ; Better highlighting by referencing to the definition, for variable
;; references. However, this is not yet supported by neovim ; references. However, this is not yet supported by neovim
;; See https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables ; See https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables
(compilation) @local.scope (compilation) @local.scope
(package_declaration) @local.scope (package_declaration) @local.scope
(package_body) @local.scope (package_body) @local.scope
(subprogram_declaration) @local.scope (subprogram_declaration) @local.scope
(subprogram_body) @local.scope (subprogram_body) @local.scope
(block_statement) @local.scope (block_statement) @local.scope
(with_clause (identifier) @local.definition.import) (with_clause
(procedure_specification name: (_) @local.definition.function) (identifier) @local.definition.import)
(function_specification name: (_) @local.definition.function)
(package_declaration name: (_) @local.definition.var) (procedure_specification
(package_body name: (_) @local.definition.var) name: (_) @local.definition.function)
(generic_instantiation . name: (_) @local.definition.var)
(component_declaration . (identifier) @local.definition.var) (function_specification
(exception_declaration . (identifier) @local.definition.var) name: (_) @local.definition.function)
(formal_object_declaration . (identifier) @local.definition.var)
(object_declaration . (identifier) @local.definition.var) (package_declaration
(parameter_specification . (identifier) @local.definition.var) name: (_) @local.definition.var)
(full_type_declaration . (identifier) @local.definition.type)
(private_type_declaration . (identifier) @local.definition.type) (package_body
(private_extension_declaration . (identifier) @local.definition.type) name: (_) @local.definition.var)
(incomplete_type_declaration . (identifier) @local.definition.type)
(protected_type_declaration . (identifier) @local.definition.type) (generic_instantiation
(formal_complete_type_declaration . (identifier) @local.definition.type) .
(formal_incomplete_type_declaration . (identifier) @local.definition.type) name: (_) @local.definition.var)
(task_type_declaration . (identifier) @local.definition.type)
(subtype_declaration . (identifier) @local.definition.type) (component_declaration
.
(identifier) @local.definition.var)
(exception_declaration
.
(identifier) @local.definition.var)
(formal_object_declaration
.
(identifier) @local.definition.var)
(object_declaration
.
(identifier) @local.definition.var)
(parameter_specification
.
(identifier) @local.definition.var)
(full_type_declaration
.
(identifier) @local.definition.type)
(private_type_declaration
.
(identifier) @local.definition.type)
(private_extension_declaration
.
(identifier) @local.definition.type)
(incomplete_type_declaration
.
(identifier) @local.definition.type)
(protected_type_declaration
.
(identifier) @local.definition.type)
(formal_complete_type_declaration
.
(identifier) @local.definition.type)
(formal_incomplete_type_declaration
.
(identifier) @local.definition.type)
(task_type_declaration
.
(identifier) @local.definition.type)
(subtype_declaration
.
(identifier) @local.definition.type)
(identifier) @local.reference (identifier) @local.reference

View file

@ -1,4 +1,4 @@
[ [
(record) (record)
(module) (module)
] @fold ] @fold

View file

@ -1,43 +1,52 @@
; Constants
;; Constants
(integer) @number (integer) @number
;; Variables and Symbols ; Variables and Symbols
(typed_binding
(atom
(qid) @variable))
(typed_binding (atom (qid) @variable))
(untyped_binding) @variable (untyped_binding) @variable
(typed_binding (expr) @type)
(typed_binding
(expr) @type)
(id) @function (id) @function
(bid) @function (bid) @function
(function_name (atom (qid) @function)) (function_name
(atom
(qid) @function))
(field_name) @function (field_name) @function
[
[(data_name) (record_name)] @constructor (data_name)
(record_name)
] @constructor
; Set ; Set
(SetN) @type.builtin (SetN) @type.builtin
(expr . (atom) @function) (expr
.
(atom) @function)
((atom) @boolean ((atom) @boolean
(#any-of? @boolean "true" "false" "True" "False")) (#any-of? @boolean "true" "false" "True" "False"))
;; Imports and Module Declarations ; Imports and Module Declarations
"import" @keyword.import
"import" @keyword.import
(module_name) @module (module_name) @module
;; Pragmas and comments ; Pragmas and comments
(pragma) @keyword.directive (pragma) @keyword.directive
(comment) @comment @spell (comment) @comment @spell
;; Keywords ; Keywords
[ [
"where" "where"
"data" "data"
@ -62,20 +71,16 @@
"infixl" "infixl"
"infixr" "infixr"
"record" "record"
] ] @keyword
@keyword
;;;(expr
;;; f_name: (atom) @function)
;; Brackets
;(expr
; f_name: (atom) @function)
; Brackets
[ [
"(" "("
")" ")"
"{" "{"
"}"] "}"
@punctuation.bracket ] @punctuation.bracket
[ "=" @operator
"="
] @operator

View file

@ -1,12 +1,19 @@
(identifier) @variable (identifier) @variable
(pipe_sequence "|" @operator)
(pipe_sequence
"|" @operator)
(string) @string (string) @string
(number) @number (number) @number
(pipe_call (pipe_call
name: (identifier) @function) name: (identifier) @function)
(pipe_call (pipe_call
arguments: (pipe_arguments arguments:
(identifier) @variable.parameter)) (pipe_arguments
(identifier) @variable.parameter))
(structural_assignment (structural_assignment
operator: (identifier) @keyword) operator: (identifier) @keyword)
@ -18,32 +25,34 @@
function: (identifier) @function) function: (identifier) @function)
(call_expression (call_expression
function: ((identifier) @function.builtin function:
(#eq? @function.builtin "$any"))) ((identifier) @function.builtin
(#eq? @function.builtin "$any")))
[ [
"let" "let"
"as" "as"
] @keyword ] @keyword
[ [
"(" "("
")" ")"
"[" "["
"]" "]"
"{" "{"
"}" "}"
] @punctuation.bracket ] @punctuation.bracket
[ [
";" ";"
"." "."
"," ","
"?." "?."
] @punctuation.delimiter ] @punctuation.delimiter
((identifier) @boolean ((identifier) @boolean
(#any-of? @boolean "true" "false")) (#any-of? @boolean "true" "false"))
((identifier) @variable.builtin ((identifier) @variable.builtin
(#any-of? @variable.builtin "this" "\$event" "null")) (#any-of? @variable.builtin "this" "\$event" "null"))

View file

@ -1,6 +1,6 @@
[ [
(class_body) (class_body)
(constructor_declaration) (constructor_declaration)
(argument_list) (argument_list)
(annotation_argument_list) (annotation_argument_list)
] @fold ] @fold

View file

@ -1,7 +1,5 @@
; inherits: soql ; inherits: soql
; Apex + SOQL
;;; Apex + SOQL
[ [
"[" "["
"]" "]"
@ -17,16 +15,14 @@
":" ":"
"?" "?"
";" ";"
] @punctuation.delimiter ] @punctuation.delimiter
;; Default general color defination
; Default general color defination
(identifier) @variable (identifier) @variable
(type_identifier) @type (type_identifier) @type
;; Methods ; Methods
(method_declaration (method_declaration
name: (identifier) @function.method) name: (identifier) @function.method)
@ -35,13 +31,11 @@
(super) @function.builtin (super) @function.builtin
;; Annotations ; Annotations
(annotation (annotation
name: (identifier) @attribute) name: (identifier) @attribute)
;; Types ; Types
(interface_declaration (interface_declaration
name: (identifier) @type) name: (identifier) @type)
@ -49,7 +43,7 @@
name: (identifier) @type) name: (identifier) @type)
(class_declaration (class_declaration
(superclass) @type) (superclass) @type)
(enum_declaration (enum_declaration
name: (identifier) @type) name: (identifier) @type)
@ -57,8 +51,11 @@
(enum_constant (enum_constant
name: (identifier) @constant) name: (identifier) @constant)
(type_arguments "<" @punctuation.delimiter) (type_arguments
(type_arguments ">" @punctuation.delimiter) "<" @punctuation.delimiter)
(type_arguments
">" @punctuation.delimiter)
((field_access ((field_access
object: (identifier) @type)) object: (identifier) @type))
@ -68,11 +65,11 @@
((scoped_identifier ((scoped_identifier
scope: (identifier) @type) scope: (identifier) @type)
(#match? @type "^[A-Z]")) (#match? @type "^[A-Z]"))
((method_invocation ((method_invocation
object: (identifier) @type) object: (identifier) @type)
(#match? @type "^[A-Z]")) (#match? @type "^[A-Z]"))
(method_declaration (method_declaration
(formal_parameters (formal_parameters
@ -86,16 +83,21 @@
(assignment_operator) @operator (assignment_operator) @operator
(update_expression ["++" "--"] @operator) (update_expression
[
"++"
"--"
] @operator)
(trigger_declaration (trigger_declaration
name: (identifier) @type name: (identifier) @type
object: (identifier) @type object: (identifier) @type
(trigger_event) @keyword (trigger_event) @keyword
("," (trigger_event) @keyword)*) (","
(trigger_event) @keyword)*)
[ [
"@" "@"
"=" "="
"!=" "!="
"<=" "<="
@ -103,35 +105,39 @@
] @operator ] @operator
(binary_expression (binary_expression
operator: [ operator:
">" [
"<" ">"
"==" "<"
"===" "=="
"!==" "==="
"&&" "!=="
"||" "&&"
"+" "||"
"-" "+"
"*" "-"
"/" "*"
"&" "/"
"|" "&"
"^" "|"
"%" "^"
"<<" "%"
">>" "<<"
">>>"] @operator) ">>"
">>>"
] @operator)
(unary_expression (unary_expression
operator: [ operator:
"+" [
"-" "+"
"!" "-"
"~" "!"
]) @operator "~"
]) @operator
(map_initializer "=>" @operator) (map_initializer
"=>" @operator)
[ [
(boolean_type) (boolean_type)
@ -139,18 +145,27 @@
] @type.builtin ] @type.builtin
; Fields ; Fields
(field_declaration (field_declaration
declarator: (variable_declarator declarator:
name: (identifier) @variable.member)) (variable_declarator
name: (identifier) @variable.member))
(field_access (field_access
field: (identifier) @variable.member) field: (identifier) @variable.member)
; Variables ; Variables
(field_declaration (field_declaration
(modifiers (modifier ["final" "static"])(modifier ["final" "static"])) (modifiers
(modifier
[
"final"
"static"
])
(modifier
[
"final"
"static"
]))
(variable_declarator (variable_declarator
name: (identifier) @constant)) name: (identifier) @constant))
@ -163,7 +178,6 @@
(this) @variable.builtin (this) @variable.builtin
; Literals ; Literals
[ [
(int) (int)
(decimal) (decimal)
@ -179,16 +193,15 @@
(null_literal) @constant.builtin (null_literal) @constant.builtin
;; ;; Keywords ; ;; Keywords
[ [
"abstract" "abstract"
"final" "final"
"private" "private"
"protected" "protected"
"public" "public"
"static" "static"
] @type.qualifier ] @type.qualifier
[ [
"if" "if"
@ -203,16 +216,14 @@
"break" "break"
] @keyword.repeat ] @keyword.repeat
[ "return" @keyword.return
"return"
] @keyword.return
[ [
"throw" "throw"
"finally" "finally"
"try" "try"
"catch" "catch"
] @keyword.exception ] @keyword.exception
"new" @keyword.operator "new" @keyword.operator

View file

@ -1,41 +1,46 @@
; declarations ; declarations
(class_declaration) @local.scope (class_declaration) @local.scope
(method_declaration) @local.scope (method_declaration) @local.scope
(constructor_declaration) @local.scope (constructor_declaration) @local.scope
(enum_declaration) @local.scope (enum_declaration) @local.scope
(enhanced_for_statement) @local.scope (enhanced_for_statement) @local.scope
; if/else ; if/else
(if_statement) @local.scope (if_statement) @local.scope
(if_statement (if_statement
consequence: (_) @local.scope) ; if body in case there are no braces consequence: (_) @local.scope) ; if body in case there are no braces
(if_statement (if_statement
alternative: (_) @local.scope) ; else body in case there are no braces alternative: (_) @local.scope) ; else body in case there are no braces
; try/catch ; try/catch
(try_statement) @local.scope ; covers try+catch, individual try and catch are covered by (block) (try_statement) @local.scope ; covers try+catch, individual try and catch are covered by (block)
(catch_clause) @local.scope ; needed because `Exception` variable (catch_clause) @local.scope ; needed because `Exception` variable
; loops ; loops
(for_statement) @local.scope (for_statement) @local.scope
(for_statement ; "for" body in case there are no braces
(for_statement ; "for" body in case there are no braces
body: (_) @local.scope) body: (_) @local.scope)
(do_statement (do_statement
body: (_) @local.scope) body: (_) @local.scope)
(while_statement (while_statement
body: (_) @local.scope) body: (_) @local.scope)
; Functions ; Functions
(constructor_declaration) @local.scope (constructor_declaration) @local.scope
(method_declaration) @local.scope (method_declaration) @local.scope
;; definitions ; definitions
(enum_declaration (enum_declaration
name: (identifier) @local.definition.enum) name: (identifier) @local.definition.enum)
@ -43,10 +48,11 @@
name: (identifier) @local.definition.method) name: (identifier) @local.definition.method)
(local_variable_declaration (local_variable_declaration
declarator: (variable_declarator declarator:
name: (identifier) @local.definition.var)) (variable_declarator
name: (identifier) @local.definition.var))
(enhanced_for_statement (enhanced_for_statement
name: (identifier) @local.definition.var) name: (identifier) @local.definition.var)
(formal_parameter (formal_parameter
@ -56,11 +62,11 @@
name: (identifier) @local.definition.parameter) name: (identifier) @local.definition.parameter)
(field_declaration (field_declaration
declarator: (variable_declarator declarator:
name: (identifier) @local.definition.field)) (variable_declarator
name: (identifier) @local.definition.field))
;; REFERENCES
; REFERENCES
(identifier) @local.reference (identifier) @local.reference
(type_identifier) @local.reference (type_identifier) @local.reference

View file

@ -1,5 +1,4 @@
; inherits: cpp ; inherits: cpp
((identifier) @function.builtin ((identifier) @function.builtin
; format-ignore ; format-ignore
(#any-of? @function.builtin (#any-of? @function.builtin
@ -72,25 +71,10 @@
"noInterrupts")) "noInterrupts"))
((identifier) @type.builtin ((identifier) @type.builtin
(#any-of? @type.builtin (#any-of? @type.builtin "Serial" "SPI" "Stream" "Wire" "Keyboard" "Mouse" "String"))
"Serial"
"SPI"
"Stream"
"Wire"
"Keyboard"
"Mouse"
"String"
))
((identifier) @constant.builtin ((identifier) @constant.builtin
(#any-of? @constant.builtin (#any-of? @constant.builtin "HIGH" "LOW" "INPUT" "OUTPUT" "INPUT_PULLUP" "LED_BUILTIN"))
"HIGH"
"LOW"
"INPUT"
"OUTPUT"
"INPUT_PULLUP"
"LED_BUILTIN"
))
(function_definition (function_definition
(function_declarator (function_declarator

View file

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

View file

@ -1,13 +1,20 @@
; inherits: html ; inherits: html
"---" @punctuation.delimiter
[ "---" ] @punctuation.delimiter [
"{"
[ "{" "}" ] @punctuation.special "}"
] @punctuation.special
; custom components get `@type` highlighting ; custom components get `@type` highlighting
((start_tag (tag_name) @type) ((start_tag
(#lua-match? @type "^[A-Z]")) (tag_name) @type)
((end_tag (tag_name) @type) (#lua-match? @type "^[A-Z]"))
(#lua-match? @type "^[A-Z]"))
((erroneous_end_tag (erroneous_end_tag_name) @type) ((end_tag
(#lua-match? @type "^[A-Z]")) (tag_name) @type)
(#lua-match? @type "^[A-Z]"))
((erroneous_end_tag
(erroneous_end_tag_name) @type)
(#lua-match? @type "^[A-Z]"))

View file

@ -1,5 +1,4 @@
; inherits: html_tags ; inherits: html_tags
(frontmatter (frontmatter
(raw_text) @injection.content (raw_text) @injection.content
(#set! injection.language "typescript")) (#set! injection.language "typescript"))
@ -13,11 +12,12 @@
(#set! injection.language "typescript")) (#set! injection.language "typescript"))
(style_element (style_element
(start_tag (start_tag
(attribute (attribute
(attribute_name) @_lang_attr (attribute_name) @_lang_attr
(quoted_attribute_value (attribute_value) @_lang_value))) (quoted_attribute_value
(raw_text) @injection.content (attribute_value) @_lang_value)))
(#eq? @_lang_attr "lang") (raw_text) @injection.content
(#eq? @_lang_value "scss") (#eq? @_lang_attr "lang")
(#set! injection.language "scss")) (#eq? @_lang_value "scss")
(#set! injection.language "scss"))

View file

@ -11,7 +11,8 @@
(identifier) @type)) (identifier) @type))
; relations ; relations
(rel_expression (identifier) @property) (rel_expression
(identifier) @property)
(relation (relation
(rel_expression (rel_expression
@ -20,16 +21,18 @@
(identifier) @constant)) (identifier) @constant))
; permissions ; permissions
(perm_expression (identifier) @property) (perm_expression
(identifier) @property)
(call_expression (call_expression
function: (selector_expression function:
operand: (identifier) @constant (selector_expression
field: (field_identifier) @function.method)) operand: (identifier) @constant
field: (field_identifier) @function.method))
(perm_expression (perm_expression
(stabby) @operator (stabby) @operator
. .
(identifier) @function) (identifier) @function)
; misc ; misc

View file

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

View file

@ -1,67 +1,54 @@
; adapted from https://github.com/Beaglefoot/tree-sitter-awk ; adapted from https://github.com/Beaglefoot/tree-sitter-awk
[ [
(identifier) (identifier)
(field_ref) (field_ref)
] @variable ] @variable
(field_ref (_) @variable)
(field_ref
(_) @variable)
; https://www.gnu.org/software/gawk/manual/html_node/Auto_002dset.html ; https://www.gnu.org/software/gawk/manual/html_node/Auto_002dset.html
((identifier) @constant.builtin ((identifier) @constant.builtin
(#any-of? @constant.builtin (#any-of? @constant.builtin "ARGC" "ARGV" "ARGIND" "ENVIRON" "ERRNO" "FILENAME" "FNR" "NF" "FUNCTAB" "NR" "PROCINFO" "RLENGTH" "RSTART" "RT" "SYMTAB"))
"ARGC"
"ARGV"
"ARGIND"
"ENVIRON"
"ERRNO"
"FILENAME"
"FNR"
"NF"
"FUNCTAB"
"NR"
"PROCINFO"
"RLENGTH"
"RSTART"
"RT"
"SYMTAB"))
; https://www.gnu.org/software/gawk/manual/html_node/User_002dmodified.html ; https://www.gnu.org/software/gawk/manual/html_node/User_002dmodified.html
((identifier) @variable.builtin ((identifier) @variable.builtin
(#any-of? @variable.builtin (#any-of? @variable.builtin "BINMODE" "CONVFMT" "FIELDWIDTHS" "FPAT" "FS" "IGNORECASE" "LINT" "OFMT" "OFS" "ORS" "PREC" "ROUNDMODE" "RS" "SUBSEP" "TEXTDOMAIN"))
"BINMODE"
"CONVFMT"
"FIELDWIDTHS"
"FPAT"
"FS"
"IGNORECASE"
"LINT"
"OFMT"
"OFS"
"ORS"
"PREC"
"ROUNDMODE"
"RS"
"SUBSEP"
"TEXTDOMAIN"))
(number) @number (number) @number
(string) @string (string) @string
(regex) @string.regexp (regex) @string.regexp
(escape_sequence) @string.escape (escape_sequence) @string.escape
(comment) @comment @spell (comment) @comment @spell
((program . (comment) @keyword.directive) ((program
.
(comment) @keyword.directive)
(#lua-match? @keyword.directive "^#!/")) (#lua-match? @keyword.directive "^#!/"))
(ns_qualified_name (namespace) @module) (ns_qualified_name
(ns_qualified_name "::" @punctuation.delimiter) (namespace) @module)
(func_def name: (_ (identifier) @function) @function) (ns_qualified_name
(func_call name: (_ (identifier) @function) @function) "::" @punctuation.delimiter)
(func_def (param_list (identifier) @variable.parameter)) (func_def
name:
(_
(identifier) @function) @function)
(func_call
name:
(_
(identifier) @function) @function)
(func_def
(param_list
(identifier) @variable.parameter))
[ [
"print" "print"
@ -110,80 +97,95 @@
"@namespace" @keyword.directive "@namespace" @keyword.directive
[ [
"BEGIN" "BEGIN"
"END" "END"
"BEGINFILE" "BEGINFILE"
"ENDFILE" "ENDFILE"
] @label ] @label
(binary_exp [ (binary_exp
"^" [
"**" "^"
"*" "**"
"/" "*"
"%" "/"
"+" "%"
"-" "+"
"<" "-"
">" "<"
"<=" ">"
">=" "<="
"==" ">="
"!=" "=="
"~" "!="
"!~" "~"
"in" "!~"
"&&" "in"
"||" "&&"
] @operator) "||"
] @operator)
(unary_exp [ (unary_exp
"!" [
"+" "!"
"-" "+"
] @operator) "-"
] @operator)
(assignment_exp [ (assignment_exp
"=" [
"+=" "="
"-=" "+="
"*=" "-="
"/=" "*="
"%=" "/="
"^=" "%="
] @operator) "^="
] @operator)
(ternary_exp [ (ternary_exp
"?" [
":" "?"
] @keyword.conditional.ternary) ":"
] @keyword.conditional.ternary)
(update_exp [ (update_exp
"++" [
"--" "++"
] @operator) "--"
] @operator)
(redirected_io_statement [ (redirected_io_statement
">" [
">>" ">"
] @operator) ">>"
] @operator)
(piped_io_statement [ (piped_io_statement
"|" [
"|&" "|"
] @operator) "|&"
] @operator)
(piped_io_exp [ (piped_io_exp
"|" [
"|&" "|"
] @operator) "|&"
] @operator)
(field_ref "$" @punctuation.delimiter) (field_ref
"$" @punctuation.delimiter)
(regex "/" @punctuation.delimiter) (regex
(regex_constant "@" @punctuation.delimiter) "/" @punctuation.delimiter)
[ ";" "," ] @punctuation.delimiter (regex_constant
"@" @punctuation.delimiter)
[
";"
","
] @punctuation.delimiter
[ [
"(" "("

View file

@ -1,13 +1,17 @@
((comment) @injection.content ((comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))
((regex) @injection.content ((regex) @injection.content
(#set! injection.language "regex")) (#set! injection.language "regex"))
((print_statement ((print_statement
(exp_list . (string) @injection.content)) (exp_list
(#set! injection.language "printf")) .
(string) @injection.content))
(#set! injection.language "printf"))
((printf_statement ((printf_statement
(exp_list . (string) @injection.content)) (exp_list
(#set! injection.language "printf")) .
(string) @injection.content))
(#set! injection.language "printf"))

View file

@ -1,84 +1,89 @@
[ [
"(" ")" "("
"{" "}" ")"
"[" "]" "{"
"[[" "]]" "}"
"((" "))" "["
"]"
"[["
"]]"
"(("
"))"
] @punctuation.bracket ] @punctuation.bracket
[ [
";" ";"
";;" ";;"
";&" ";&"
";;&" ";;&"
"&" "&"
] @punctuation.delimiter ] @punctuation.delimiter
[ [
">" ">"
">>" ">>"
"<" "<"
"<<" "<<"
"&&" "&&"
"|" "|"
"|&" "|&"
"||" "||"
"=" "="
"+=" "+="
"=~" "=~"
"==" "=="
"!=" "!="
"&>"
"&>" "&>>"
"&>>" "<&"
"<&" ">&"
">&" ">|"
">|" "<&-"
"<&-" ">&-"
">&-" "<<-"
"<<<"
"<<-" ".."
"<<<"
".."
] @operator ] @operator
; Do *not* spell check strings since they typically have some sort of ; Do *not* spell check strings since they typically have some sort of
; interpolation in them, or, are typically used for things like filenames, URLs, ; interpolation in them, or, are typically used for things like filenames, URLs,
; flags and file content. ; flags and file content.
[ [
(string) (string)
(raw_string) (raw_string)
(ansi_c_string) (ansi_c_string)
(heredoc_body) (heredoc_body)
] @string ] @string
[ [
(heredoc_start) (heredoc_start)
(heredoc_end) (heredoc_end)
] @label ] @label
(variable_assignment (word) @string) (variable_assignment
(command argument: "$" @string) ; bare dollar (word) @string)
(command
argument: "$" @string) ; bare dollar
[ [
"if" "if"
"then" "then"
"else" "else"
"elif" "elif"
"fi" "fi"
"case" "case"
"in" "in"
"esac" "esac"
] @keyword.conditional ] @keyword.conditional
[ [
"for" "for"
"do" "do"
"done" "done"
"select" "select"
"until" "until"
"while" "while"
] @keyword.repeat ] @keyword.repeat
[ [
@ -97,36 +102,54 @@
; trap -l ; trap -l
((word) @constant.builtin ((word) @constant.builtin
(#match? @constant.builtin "^SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR[12]|SEGV|PIPE|ALRM|TERM|STKFLT|CHLD|CONT|STOP|TSTP|TT(IN|OU)|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS|RTMIN([+]([1-9]|1[0-5]))?|RTMAX(-([1-9]|1[0-4]))?)$")) (#match? @constant.builtin "^SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR[12]|SEGV|PIPE|ALRM|TERM|STKFLT|CHLD|CONT|STOP|TSTP|TT(IN|OU)|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS|RTMIN([+]([1-9]|1[0-5]))?|RTMAX(-([1-9]|1[0-4]))?)$"))
((word) @boolean ((word) @boolean
(#any-of? @boolean "true" "false")) (#any-of? @boolean "true" "false"))
(comment) @comment @spell (comment) @comment @spell
(test_operator) @operator (test_operator) @operator
(command_substitution "$(" @punctuation.bracket) (command_substitution
(process_substitution "<(" @punctuation.bracket) "$(" @punctuation.bracket)
(process_substitution
"<(" @punctuation.bracket)
(arithmetic_expansion (arithmetic_expansion
[ "$((" "((" ] @punctuation.special [
"$(("
"(("
] @punctuation.special
"))" @punctuation.special) "))" @punctuation.special)
(arithmetic_expansion "," @punctuation.delimiter) (arithmetic_expansion
"," @punctuation.delimiter)
(ternary_expression [ "?" ":" ] @keyword.conditional.ternary) (ternary_expression
[
"?"
":"
] @keyword.conditional.ternary)
(binary_expression operator: _ @operator) (binary_expression
(unary_expression operator: _ @operator) operator: _ @operator)
(postfix_expression operator: _ @operator)
(unary_expression
operator: _ @operator)
(postfix_expression
operator: _ @operator)
(function_definition (function_definition
name: (word) @function) name: (word) @function)
(command_name (word) @function.call) (command_name
(word) @function.call)
((command_name (word) @function.builtin) ((command_name
(word) @function.builtin)
; format-ignore ; format-ignore
(#any-of? @function.builtin (#any-of? @function.builtin
"alias" "bg" "bind" "break" "builtin" "caller" "cd" "alias" "bg" "bind" "break" "builtin" "caller" "cd"
@ -140,14 +163,17 @@
"ulimit" "umask" "unalias" "wait")) "ulimit" "umask" "unalias" "wait"))
(command (command
argument: [ argument:
(word) @variable.parameter [
(concatenation (word) @variable.parameter) (word) @variable.parameter
]) (concatenation
(word) @variable.parameter)
])
(number) @number (number) @number
((word) @number ((word) @number
(#lua-match? @number "^[0-9]+$")) (#lua-match? @number "^[0-9]+$"))
(file_redirect (file_redirect
destination: (word) @variable.parameter) destination: (word) @variable.parameter)
@ -156,24 +182,30 @@
(simple_expansion (simple_expansion
"$" @punctuation.special) @none "$" @punctuation.special) @none
(expansion (expansion
"${" @punctuation.special "${" @punctuation.special
"}" @punctuation.special) @none "}" @punctuation.special) @none
(expansion operator: _ @punctuation.special) (expansion
(expansion "@" . operator: _ @character.special) operator: _ @punctuation.special)
(expansion
"@"
.
operator: _ @character.special)
((expansion ((expansion
(subscript (subscript
index: (word) @character.special)) index: (word) @character.special))
(#any-of? @character.special "@" "*")) (#any-of? @character.special "@" "*"))
"``" @punctuation.special "``" @punctuation.special
(variable_name) @variable (variable_name) @variable
((variable_name) @constant ((variable_name) @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
(case_item (case_item
value: (word) @variable.parameter) value: (word) @variable.parameter)
@ -183,5 +215,7 @@
(extglob_pattern) (extglob_pattern)
] @string.regexp ] @string.regexp
((program . (comment) @keyword.directive) ((program
(#lua-match? @keyword.directive "^#!/")) .
(comment) @keyword.directive)
(#lua-match? @keyword.directive "^#!/"))

View file

@ -1,35 +1,52 @@
((comment) @injection.content ((comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))
((regex) @injection.content ((regex) @injection.content
(#set! injection.language "regex")) (#set! injection.language "regex"))
((heredoc_redirect ((heredoc_redirect
(heredoc_body) @injection.content (heredoc_body) @injection.content
(heredoc_end) @injection.language) (heredoc_end) @injection.language)
(#downcase! @injection.language)) (#downcase! @injection.language))
; printf 'format' ; printf 'format'
((command ((command
name: (command_name) @_command name: (command_name) @_command
. argument: [(string) (raw_string)] @injection.content) .
(#eq? @_command "printf") argument:
(#set! injection.language "printf")) [
(string)
(raw_string)
] @injection.content)
(#eq? @_command "printf")
(#set! injection.language "printf"))
; printf -v var 'format' ; printf -v var 'format'
((command ((command
name: (command_name) @_command name: (command_name) @_command
argument: (word) @_arg argument: (word) @_arg
. (_) . argument: [(string) (raw_string)] @injection.content) .
(#eq? @_command "printf") (_)
(#eq? @_arg "-v") .
(#set! injection.language "printf")) argument:
[
(string)
(raw_string)
] @injection.content)
(#eq? @_command "printf")
(#eq? @_arg "-v")
(#set! injection.language "printf"))
; printf -- 'format' ; printf -- 'format'
((command ((command
name: (command_name) @_command name: (command_name) @_command
argument: (word) @_arg argument: (word) @_arg
. argument: [(string) (raw_string)] @injection.content) .
(#eq? @_command "printf") argument:
(#eq? @_arg "--") [
(#set! injection.language "printf")) (string)
(raw_string)
] @injection.content)
(#eq? @_command "printf")
(#eq? @_arg "--")
(#set! injection.language "printf"))

View file

@ -2,7 +2,7 @@
(function_definition) @local.scope (function_definition) @local.scope
; Definitions ; Definitions
(variable_assignment (variable_assignment
name: (variable_name) @local.definition.var) name: (variable_name) @local.definition.var)
(function_definition (function_definition
@ -10,4 +10,5 @@
; References ; References
(variable_name) @local.reference (variable_name) @local.reference
(word) @local.reference (word) @local.reference

View file

@ -1,54 +1,56 @@
;; Variables ; Variables
(list
(symbol) @variable)
(list (symbol) @variable) (cons
(symbol) @variable)
(cons (symbol) @variable) (scope
(symbol) @variable)
(scope (symbol) @variable) (symbind
(symbol) @variable)
(symbind (symbol) @variable)
;; Constants
; Constants
((symbol) @constant ((symbol) @constant
(#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$")) (#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$"))
;; Functions ; Functions
(list
(list .
. (symbol) @function) (symbol) @function)
;; Namespaces
; Namespaces
(symbind (symbind
(symbol) @module (symbol) @module
. (keyword)) .
(keyword))
;; Includes
; Includes
((symbol) @keyword.import ((symbol) @keyword.import
(#any-of? @keyword.import "use" "import" "load")) (#any-of? @keyword.import "use" "import" "load"))
;; Keywords ; Keywords
((symbol) @keyword ((symbol) @keyword
(#any-of? @keyword "do" "doc")) (#any-of? @keyword "do" "doc"))
;; Special Functions ; Special Functions
; Keywords construct a symbol ; Keywords construct a symbol
(keyword) @constructor (keyword) @constructor
((list ((list
. (symbol) @keyword.function .
. (symbol) @function (symbol) @keyword.function
.
(symbol) @function
(symbol)? @variable.parameter) (symbol)? @variable.parameter)
(#any-of? @keyword.function "def" "defop" "defn" "fn")) (#any-of? @keyword.function "def" "defop" "defn" "fn"))
((cons ((cons
. (symbol) @keyword.function .
. (symbol) @function (symbol) @keyword.function
.
(symbol) @function
(symbol)? @variable.parameter) (symbol)? @variable.parameter)
(#any-of? @keyword.function "def" "defop" "defn" "fn")) (#any-of? @keyword.function "def" "defop" "defn" "fn"))
@ -58,33 +60,38 @@
((symbol) @function.macro ((symbol) @function.macro
(#any-of? @function.macro "op" "current-scope" "quote" "let" "provide" "module" "or" "and" "curryfn" "for" "$" "linux")) (#any-of? @function.macro "op" "current-scope" "quote" "let" "provide" "module" "or" "and" "curryfn" "for" "$" "linux"))
;; Conditionals ; Conditionals
((symbol) @keyword.conditional ((symbol) @keyword.conditional
(#any-of? @keyword.conditional "if" "case" "cond" "when")) (#any-of? @keyword.conditional "if" "case" "cond" "when"))
;; Repeats ; Repeats
((symbol) @keyword.repeat ((symbol) @keyword.repeat
(#any-of? @keyword.repeat "each")) (#any-of? @keyword.repeat "each"))
;; Operators ; Operators
((symbol) @operator
(#any-of? @operator "&" "*" "+" "-" "<" "<=" "=" ">" ">="))
((symbol) @operator (#any-of? @operator "&" "*" "+" "-" "<" "<=" "=" ">" ">=")) ; Punctuation
[
"("
")"
] @punctuation.bracket
;; Punctuation [
"{"
"}"
] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket [
"["
[ "{" "}" ] @punctuation.bracket "]"
] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
((symbol) @punctuation.delimiter ((symbol) @punctuation.delimiter
(#eq? @punctuation.delimiter "->")) (#eq? @punctuation.delimiter "->"))
;; Literals ; Literals
(string) @string (string) @string
(escape_sequence) @string.escape (escape_sequence) @string.escape
@ -100,10 +107,7 @@
(null) (null)
] @constant.builtin ] @constant.builtin
[ "^" @character.special
"^"
] @character.special
;; Comments
; Comments
(comment) @comment @spell (comment) @comment @spell

View file

@ -10,11 +10,20 @@
"]" "]"
] @indent.end ] @indent.end
[ "(" ")" ] @indent.branch [
"("
")"
] @indent.branch
[ "{" "}" ] @indent.branch [
"{"
"}"
] @indent.branch
[ "[" "]" ] @indent.branch [
"["
"]"
] @indent.branch
[ [
(ERROR) (ERROR)

View file

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

View file

@ -1,5 +1,4 @@
; Scopes ; Scopes
[ [
(list) (list)
(scope) (scope)
@ -7,19 +6,21 @@
] @local.scope ] @local.scope
; References ; References
(symbol) @local.reference (symbol) @local.reference
; Definitions ; Definitions
((list ((list
. (symbol) @_fnkw .
. (symbol) @local.definition.function (symbol) @_fnkw
.
(symbol) @local.definition.function
(symbol)? @local.definition.parameter) (symbol)? @local.definition.parameter)
(#any-of? @_fnkw "def" "defop" "defn" "fn")) (#any-of? @_fnkw "def" "defop" "defn" "fn"))
((cons ((cons
. (symbol) @_fnkw .
. (symbol) @local.definition.function (symbol) @_fnkw
.
(symbol) @local.definition.function
(symbol)? @local.definition.parameter) (symbol)? @local.definition.parameter)
(#any-of? @_fnkw "def" "defop" "defn" "fn")) (#any-of? @_fnkw "def" "defop" "defn" "fn"))

View file

@ -1,4 +1,4 @@
[ [
(transaction) (transaction)
(section) (section)
] @fold ] @fold

View file

@ -1,24 +1,57 @@
(date) @variable.member (date) @variable.member
(txn) @attribute (txn) @attribute
(account) @type (account) @type
(amount) @number (amount) @number
(incomplete_amount) @number (incomplete_amount) @number
(compound_amount) @number (compound_amount) @number
(amount_tolerance) @number (amount_tolerance) @number
(currency) @property (currency) @property
(key) @label (key) @label
(string) @string (string) @string
(narration) @string @spell (narration) @string @spell
(payee) @string @spell (payee) @string @spell
(tag) @constant (tag) @constant
(link) @constant (link) @constant
[ [
(minus) (plus) (slash) (asterisk) (minus)
(plus)
(slash)
(asterisk)
] @operator ] @operator
(comment) @comment @spell (comment) @comment @spell
[ [
(balance) (open) (close) (commodity) (pad) (balance)
(event) (price) (note) (document) (query) (open)
(custom) (pushtag) (poptag) (pushmeta) (close)
(popmeta) (option) (include) (plugin) (commodity)
(pad)
(event)
(price)
(note)
(document)
(query)
(custom)
(pushtag)
(poptag)
(pushmeta)
(popmeta)
(option)
(include)
(plugin)
] @keyword ] @keyword

View file

@ -1,3 +1 @@
[ (entry) @fold
(entry)
] @fold

View file

@ -1,5 +1,4 @@
; CREDITS @pfoerster (adapted from https://github.com/latex-lsp/tree-sitter-bibtex) ; CREDITS @pfoerster (adapted from https://github.com/latex-lsp/tree-sitter-bibtex)
[ [
(string_type) (string_type)
(preamble_type) (preamble_type)

View file

@ -1,10 +1,8 @@
[ (entry) @indent.begin
(entry)
] @indent.begin
[ [
"{" "{"
"}" "}"
] @indent.branch ] @indent.branch
(comment) @indent.ignore (comment) @indent.ignore

View file

@ -6,20 +6,14 @@
(resource_declaration) (resource_declaration)
(type_declaration) (type_declaration)
(variable_declaration) (variable_declaration)
(parenthesized_expression) (parenthesized_expression)
(decorators) (decorators)
(array) (array)
(object) (object)
(if_statement) (if_statement)
(for_statement) (for_statement)
(subscript_expression) (subscript_expression)
(ternary_expression) (ternary_expression)
(string) (string)
(comment) (comment)
] @fold ] @fold

View file

@ -1,5 +1,4 @@
; Includes ; Includes
(import_statement (import_statement
"import" @keyword.import) "import" @keyword.import)
@ -8,12 +7,10 @@
"with" @keyword.import) "with" @keyword.import)
; Namespaces ; Namespaces
(module_declaration (module_declaration
(identifier) @module) (identifier) @module)
; Builtins ; Builtins
(primitive_type) @type.builtin (primitive_type) @type.builtin
((member_expression ((member_expression
@ -21,12 +18,10 @@
(#eq? @type.builtin "sys")) (#eq? @type.builtin "sys"))
; Functions ; Functions
(call_expression (call_expression
function: (identifier) @function.call) function: (identifier) @function.call)
; Properties ; Properties
(object_property (object_property
(identifier) @property (identifier) @property
":" @punctuation.delimiter ":" @punctuation.delimiter
@ -40,21 +35,20 @@
(property_identifier) @property (property_identifier) @property
; Attributes ; Attributes
(decorator (decorator
"@" @attribute) "@" @attribute)
(decorator (decorator
(call_expression (identifier) @attribute)) (call_expression
(identifier) @attribute))
(decorator (decorator
(call_expression (call_expression
(member_expression (member_expression
object: (identifier) @attribute object: (identifier) @attribute
property: (property_identifier) @attribute))) property: (property_identifier) @attribute)))
; Types ; Types
(type_declaration (type_declaration
(identifier) @type) (identifier) @type)
@ -66,7 +60,8 @@
(type_declaration (type_declaration
(identifier) (identifier)
"=" "="
(array_type (identifier) @type)) (array_type
(identifier) @type))
(type (type
(identifier) @type) (identifier) @type)
@ -78,21 +73,22 @@
(identifier) @type) (identifier) @type)
; Parameters ; Parameters
(parameter_declaration (parameter_declaration
(identifier) @variable.parameter (identifier) @variable.parameter
(_)) (_))
(call_expression (call_expression
function: (_) function: (_)
(arguments (identifier) @variable.parameter)) (arguments
(identifier) @variable.parameter))
(call_expression (call_expression
function: (_) function: (_)
(arguments (member_expression object: (identifier) @variable.parameter))) (arguments
(member_expression
object: (identifier) @variable.parameter)))
; Variables ; Variables
(variable_declaration (variable_declaration
(identifier) @variable (identifier) @variable
(_)) (_))
@ -117,7 +113,6 @@
(loop_enumerator) @variable)) (loop_enumerator) @variable))
; Conditionals ; Conditionals
"if" @keyword.conditional "if" @keyword.conditional
(ternary_expression (ternary_expression
@ -125,14 +120,12 @@
":" @keyword.conditional.ternary) ":" @keyword.conditional.ternary)
; Loops ; Loops
(for_statement (for_statement
"for" @keyword.repeat "for" @keyword.repeat
"in" "in"
":" @punctuation.delimiter) ":" @punctuation.delimiter)
; Keywords ; Keywords
[ [
"module" "module"
"metadata" "metadata"
@ -146,7 +139,6 @@
] @keyword ] @keyword
; Operators ; Operators
[ [
"+" "+"
"-" "-"
@ -169,14 +161,11 @@
"!" "!"
] @operator ] @operator
[ "in" @keyword.operator
"in"
] @keyword.operator
; Literals ; Literals
(string) @string (string) @string
(import_string (import_string
"'" @string "'" @string
(import_name) @module (import_name) @module
@ -192,17 +181,25 @@
(null) @constant.builtin (null) @constant.builtin
; Misc ; Misc
(compatible_identifier (compatible_identifier
"?" @punctuation.special) "?" @punctuation.special)
(nullable_return_type) @punctuation.special (nullable_return_type) @punctuation.special
["{" "}"] @punctuation.bracket [
"{"
"}"
] @punctuation.bracket
["[" "]"] @punctuation.bracket [
"["
"]"
] @punctuation.bracket
["(" ")"] @punctuation.bracket [
"("
")"
] @punctuation.bracket
[ [
"." "."
@ -210,9 +207,7 @@
"=>" "=>"
] @punctuation.delimiter ] @punctuation.delimiter
; Interpolation ; Interpolation
(interpolation) @none (interpolation) @none
(interpolation (interpolation
@ -223,7 +218,6 @@
(identifier) @variable) (identifier) @variable)
; Comments ; Comments
[ [
(comment) (comment)
(diagnostic_comment) (diagnostic_comment)

View file

@ -5,11 +5,20 @@
"}" @indent.end "}" @indent.end
[ "{" "}" ] @indent.branch [
"{"
"}"
] @indent.branch
[ "[" "]" ] @indent.branch [
"["
"]"
] @indent.branch
[ "(" ")" ] @indent.branch [
"("
")"
] @indent.branch
[ [
(ERROR) (ERROR)

View file

@ -1,5 +1,5 @@
([ ([
(comment) (comment)
(diagnostic_comment) (diagnostic_comment)
] @injection.content ] @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))

View file

@ -1,22 +1,17 @@
; Scopes ; Scopes
[ [
(infrastructure) (infrastructure)
(call_expression) (call_expression)
(lambda_expression) (lambda_expression)
(subscript_expression) (subscript_expression)
(if_statement) (if_statement)
(for_statement) (for_statement)
(array) (array)
(object) (object)
(interpolation) (interpolation)
] @local.scope ] @local.scope
; References ; References
(property_identifier) @local.reference (property_identifier) @local.reference
(call_expression (call_expression
@ -31,7 +26,6 @@
(identifier) @local.reference) (identifier) @local.reference)
; Definitions ; Definitions
(type) @local.definition.associated (type) @local.definition.associated
(object_property (object_property

View file

@ -2,28 +2,23 @@
(function_definition) (function_definition)
(anonymous_python_function) (anonymous_python_function)
(python_function_definition) (python_function_definition)
(while_statement) (while_statement)
(for_statement) (for_statement)
(if_statement) (if_statement)
(with_statement) (with_statement)
(try_statement) (try_statement)
(import_from_statement) (import_from_statement)
(parameters) (parameters)
(argument_list) (argument_list)
(parenthesized_expression) (parenthesized_expression)
(generator_expression) (generator_expression)
(list_comprehension) (list_comprehension)
(set_comprehension) (set_comprehension)
(dictionary_comprehension) (dictionary_comprehension)
(tuple) (tuple)
(list) (list)
(set) (set)
(dictionary) (dictionary)
(string) (string)
(python_string) (python_string)
] @fold ] @fold

View file

@ -1,5 +1,4 @@
; Includes ; Includes
[ [
"inherit" "inherit"
"include" "include"
@ -9,12 +8,10 @@
] @keyword.import ] @keyword.import
; Keywords ; Keywords
[ [
"unset" "unset"
"EXPORT_FUNCTIONS" "EXPORT_FUNCTIONS"
"python" "python"
"assert" "assert"
"exec" "exec"
"global" "global"
@ -34,19 +31,34 @@
"return" "return"
"yield" "yield"
] @keyword.return ] @keyword.return
(yield "from" @keyword.return)
(yield
"from" @keyword.return)
(future_import_statement (future_import_statement
"from" @keyword.import "from" @keyword.import
"__future__" @constant.builtin) "__future__" @constant.builtin)
(import_from_statement "from" @keyword.import)
(import_from_statement
"from" @keyword.import)
"import" @keyword.import "import" @keyword.import
(aliased_import "as" @keyword.import) (aliased_import
"as" @keyword.import)
["if" "elif" "else"] @keyword.conditional [
"if"
"elif"
"else"
] @keyword.conditional
["for" "while" "break" "continue"] @keyword.repeat [
"for"
"while"
"break"
"continue"
] @keyword.repeat
[ [
"try" "try"
@ -56,7 +68,8 @@
"finally" "finally"
] @keyword.exception ] @keyword.exception
(raise_statement "from" @keyword.exception) (raise_statement
"from" @keyword.exception)
(try_statement (try_statement
(else_clause (else_clause
@ -82,7 +95,6 @@
] @type.qualifier ] @type.qualifier
; Variables ; Variables
[ [
(identifier) (identifier)
(python_identifier) (python_identifier)
@ -99,14 +111,18 @@
; Reset highlighting in f-string interpolations ; Reset highlighting in f-string interpolations
(interpolation) @none (interpolation) @none
;; Identifier naming conventions ; Identifier naming conventions
((python_identifier) @type ((python_identifier) @type
(#lua-match? @type "^[A-Z].*[a-z]")) (#lua-match? @type "^[A-Z].*[a-z]"))
([(identifier) (python_identifier)] @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) ([
(identifier)
(python_identifier)
] @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
((python_identifier) @constant.builtin ((python_identifier) @constant.builtin
(#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$")) (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
((python_identifier) @constant.builtin ((python_identifier) @constant.builtin
; format-ignore ; format-ignore
@ -117,128 +133,149 @@
((assignment ((assignment
left: (python_identifier) @type.definition left: (python_identifier) @type.definition
(type (python_identifier) @_annotation)) (type
(#eq? @_annotation "TypeAlias")) (python_identifier) @_annotation))
(#eq? @_annotation "TypeAlias"))
((assignment ((assignment
left: (python_identifier) @type.definition left: (python_identifier) @type.definition
right: (call right:
function: (python_identifier) @_func)) (call
(#any-of? @_func "TypeVar" "NewType")) function: (python_identifier) @_func))
(#any-of? @_func "TypeVar" "NewType"))
; Fields ; Fields
(flag) @variable.member (flag) @variable.member
((attribute ((attribute
attribute: (python_identifier) @variable.member) attribute: (python_identifier) @variable.member)
(#lua-match? @variable.member "^[%l_].*$")) (#lua-match? @variable.member "^[%l_].*$"))
; Functions ; Functions
(call (call
function: (python_identifier) @function.call) function: (python_identifier) @function.call)
(call (call
function: (attribute function:
attribute: (python_identifier) @function.method.call)) (attribute
attribute: (python_identifier) @function.method.call))
((call ((call
function: (python_identifier) @constructor) function: (python_identifier) @constructor)
(#lua-match? @constructor "^%u")) (#lua-match? @constructor "^%u"))
((call ((call
function: (attribute function:
attribute: (python_identifier) @constructor)) (attribute
(#lua-match? @constructor "^%u")) attribute: (python_identifier) @constructor))
(#lua-match? @constructor "^%u"))
((call ((call
function: (python_identifier) @function.builtin) function: (python_identifier) @function.builtin)
(#any-of? @function.builtin (#any-of? @function.builtin "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" "classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview" "min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type" "vars" "zip" "__import__"))
"abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" "classmethod"
"compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" "filter" "float" "format"
"frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance" "issubclass"
"iter" "len" "list" "locals" "map" "max" "memoryview" "min" "next" "object" "oct" "open" "ord" "pow"
"print" "property" "range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted" "staticmethod" "str"
"sum" "super" "tuple" "type" "vars" "zip" "__import__"))
(python_function_definition (python_function_definition
name: (python_identifier) @function) name: (python_identifier) @function)
(type (python_identifier) @type) (type
(python_identifier) @type)
(type (type
(subscript (subscript
(python_identifier) @type)) ; type subscript: Tuple[int] (python_identifier) @type)) ; type subscript: Tuple[int]
((call ((call
function: (python_identifier) @_isinstance function: (python_identifier) @_isinstance
arguments: (argument_list arguments:
(_) (argument_list
(python_identifier) @type)) (_)
(#eq? @_isinstance "isinstance")) (python_identifier) @type))
(#eq? @_isinstance "isinstance"))
(anonymous_python_function (identifier) @function) (anonymous_python_function
(identifier) @function)
(function_definition (identifier) @function) (function_definition
(identifier) @function)
(addtask_statement (identifier) @function) (addtask_statement
(identifier) @function)
(deltask_statement (identifier) @function) (deltask_statement
(identifier) @function)
(export_functions_statement (identifier) @function) (export_functions_statement
(identifier) @function)
(addhandler_statement (identifier) @function) (addhandler_statement
(identifier) @function)
(python_function_definition (python_function_definition
body: body:
(block (block
. (expression_statement (python_string) @string.documentation @spell))) .
(expression_statement
(python_string) @string.documentation @spell)))
; Namespace ; Namespace
(inherit_path) @module (inherit_path) @module
;; Normal parameters ; Normal parameters
(parameters (parameters
(python_identifier) @variable.parameter) (python_identifier) @variable.parameter)
;; Lambda parameters
; Lambda parameters
(lambda_parameters (lambda_parameters
(python_identifier) @variable.parameter) (python_identifier) @variable.parameter)
(lambda_parameters (lambda_parameters
(tuple_pattern (tuple_pattern
(python_identifier) @variable.parameter)) (python_identifier) @variable.parameter))
; Default parameters ; Default parameters
(keyword_argument (keyword_argument
name: (python_identifier) @variable.parameter) name: (python_identifier) @variable.parameter)
; Naming parameters on call-site ; Naming parameters on call-site
(default_parameter (default_parameter
name: (python_identifier) @variable.parameter) name: (python_identifier) @variable.parameter)
(typed_parameter (typed_parameter
(python_identifier) @variable.parameter) (python_identifier) @variable.parameter)
(typed_default_parameter (typed_default_parameter
(python_identifier) @variable.parameter) (python_identifier) @variable.parameter)
; Variadic parameters *args, **kwargs ; Variadic parameters *args, **kwargs
(parameters (parameters
(list_splat_pattern ; *args (list_splat_pattern
; *args
(python_identifier) @variable.parameter)) (python_identifier) @variable.parameter))
(parameters (parameters
(dictionary_splat_pattern ; **kwargs (dictionary_splat_pattern
; **kwargs
(python_identifier) @variable.parameter)) (python_identifier) @variable.parameter))
;; Literals ; Literals
(none) @constant.builtin (none) @constant.builtin
[(true) (false)] @boolean
[
(true)
(false)
] @boolean
((python_identifier) @variable.builtin ((python_identifier) @variable.builtin
(#eq? @variable.builtin "self")) (#eq? @variable.builtin "self"))
((python_identifier) @variable.builtin ((python_identifier) @variable.builtin
(#eq? @variable.builtin "cls")) (#eq? @variable.builtin "cls"))
(integer) @number (integer) @number
(float) @number.float (float) @number.float
; Operators ; Operators
[ [
"?=" "?="
"??=" "??="
@ -293,12 +330,10 @@
"or" "or"
"is not" "is not"
"not in" "not in"
"del" "del"
] @keyword.operator ] @keyword.operator
; Literals ; Literals
[ [
(string) (string)
(python_string) (python_string)
@ -313,8 +348,14 @@
] @string.escape ] @string.escape
; Punctuation ; Punctuation
[
[ "(" ")" "{" "}" "[" "]" ] @punctuation.bracket "("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
[ [
":" ":"
@ -325,15 +366,28 @@
(ellipsis) (ellipsis)
] @punctuation.delimiter ] @punctuation.delimiter
(variable_expansion [ "${" "}" ] @punctuation.special) (variable_expansion
(inline_python [ "${@" "}" ] @punctuation.special) [
"${"
"}"
] @punctuation.special)
(inline_python
[
"${@"
"}"
] @punctuation.special)
(interpolation (interpolation
"{" @punctuation.special "{" @punctuation.special
"}" @punctuation.special) "}" @punctuation.special)
(type_conversion) @function.macro (type_conversion) @function.macro
([(identifier) (python_identifier)] @type.builtin ([
(identifier)
(python_identifier)
] @type.builtin
; format-ignore ; format-ignore
(#any-of? @type.builtin (#any-of? @type.builtin
; https://docs.python.org/3/library/exceptions.html ; https://docs.python.org/3/library/exceptions.html

View file

@ -1,76 +1,101 @@
[ [
(import_from_statement) (import_from_statement)
(parenthesized_expression) (parenthesized_expression)
(generator_expression) (generator_expression)
(list_comprehension) (list_comprehension)
(set_comprehension) (set_comprehension)
(dictionary_comprehension) (dictionary_comprehension)
(tuple_pattern) (tuple_pattern)
(list_pattern) (list_pattern)
(binary_operator) (binary_operator)
(lambda) (lambda)
(concatenated_string) (concatenated_string)
] @indent.begin ] @indent.begin
((list) @indent.align ((list) @indent.align
(#set! indent.open_delimiter "[") (#set! indent.open_delimiter "[")
(#set! indent.close_delimiter "]") (#set! indent.close_delimiter "]"))
)
((dictionary) @indent.align ((dictionary) @indent.align
(#set! indent.open_delimiter "{") (#set! indent.open_delimiter "{")
(#set! indent.close_delimiter "}") (#set! indent.close_delimiter "}"))
)
((set) @indent.align ((set) @indent.align
(#set! indent.open_delimiter "{") (#set! indent.open_delimiter "{")
(#set! indent.close_delimiter "}") (#set! indent.close_delimiter "}"))
)
((for_statement) @indent.begin ((for_statement) @indent.begin
(#set! indent.immediate 1)) (#set! indent.immediate 1))
((if_statement) @indent.begin ((if_statement) @indent.begin
(#set! indent.immediate 1)) (#set! indent.immediate 1))
((while_statement) @indent.begin ((while_statement) @indent.begin
(#set! indent.immediate 1)) (#set! indent.immediate 1))
((try_statement) @indent.begin ((try_statement) @indent.begin
(#set! indent.immediate 1)) (#set! indent.immediate 1))
(ERROR "try" ":" @indent.begin (#set! indent.immediate 1))
(ERROR
"try"
":" @indent.begin
(#set! indent.immediate 1))
((python_function_definition) @indent.begin ((python_function_definition) @indent.begin
(#set! indent.immediate 1)) (#set! indent.immediate 1))
(function_definition) @indent.begin (function_definition) @indent.begin
(anonymous_python_function) @indent.begin (anonymous_python_function) @indent.begin
((with_statement) @indent.begin ((with_statement) @indent.begin
(#set! indent.immediate 1)) (#set! indent.immediate 1))
(if_statement (if_statement
condition: (parenthesized_expression) @indent.align condition: (parenthesized_expression) @indent.align
(#set! indent.open_delimiter "(") (#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")") (#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1)) (#set! indent.avoid_last_matching_next 1))
(while_statement (while_statement
condition: (parenthesized_expression) @indent.align condition: (parenthesized_expression) @indent.align
(#set! indent.open_delimiter "(") (#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")") (#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1)) (#set! indent.avoid_last_matching_next 1))
(ERROR "(" @indent.align (#set! indent.open_delimiter "(") (#set! indent.close_delimiter ")") . (_)) (ERROR
"(" @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
.
(_))
((argument_list) @indent.align ((argument_list) @indent.align
(#set! indent.open_delimiter "(") (#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")) (#set! indent.close_delimiter ")"))
((parameters) @indent.align ((parameters) @indent.align
(#set! indent.open_delimiter "(") (#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")") (#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1)) (#set! indent.avoid_last_matching_next 1))
((tuple) @indent.align ((tuple) @indent.align
(#set! indent.open_delimiter "(") (#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")) (#set! indent.close_delimiter ")"))
(ERROR "[" @indent.align (#set! indent.open_delimiter "[") (#set! indent.close_delimiter "]") . (_)) (ERROR
"[" @indent.align
(#set! indent.open_delimiter "[")
(#set! indent.close_delimiter "]")
.
(_))
(ERROR "{" @indent.align (#set! indent.open_delimiter "{") (#set! indent.close_delimiter "}") . (_)) (ERROR
"{" @indent.align
(#set! indent.open_delimiter "{")
(#set! indent.close_delimiter "}")
.
(_))
[ [
(break_statement) (break_statement)
@ -78,24 +103,43 @@
] @indent.dedent ] @indent.dedent
(ERROR (ERROR
(_) @indent.branch ":" . (_) @indent.branch
":"
.
(#lua-match? @indent.branch "^else")) (#lua-match? @indent.branch "^else"))
(ERROR (ERROR
(_) @indent.branch @indent.dedent ":" . (_) @indent.branch @indent.dedent
":"
.
(#lua-match? @indent.branch "^elif")) (#lua-match? @indent.branch "^elif"))
(parenthesized_expression ")" @indent.end) (parenthesized_expression
(generator_expression ")" @indent.end) ")" @indent.end)
(list_comprehension "]" @indent.end)
(set_comprehension "}" @indent.end)
(dictionary_comprehension "}" @indent.end)
(tuple_pattern ")" @indent.end) (generator_expression
(list_pattern "]" @indent.end) ")" @indent.end)
(function_definition "}" @indent.end) (list_comprehension
(anonymous_python_function "}" @indent.end) "]" @indent.end)
(set_comprehension
"}" @indent.end)
(dictionary_comprehension
"}" @indent.end)
(tuple_pattern
")" @indent.end)
(list_pattern
"]" @indent.end)
(function_definition
"}" @indent.end)
(anonymous_python_function
"}" @indent.end)
(return_statement (return_statement
[ [
@ -107,10 +151,12 @@
"}" "}"
"]" "]"
] @indent.end .) ] @indent.end .)
(attribute (attribute
attribute: (_) @indent.end) attribute: (_) @indent.end)
(call (call
arguments: (_ ")" @indent.end)) arguments:
(_
")" @indent.end))
"return" @indent.end "return" @indent.end
] .) ] .)

View file

@ -1,8 +1,11 @@
(call (call
function: (attribute function:
object: (python_identifier) @_re) (attribute
arguments: (argument_list (python_string object: (python_identifier) @_re)
(string_content) @injection.content) @_string) arguments:
(argument_list
(python_string
(string_content) @injection.content) @_string)
(#eq? @_re "re") (#eq? @_re "re")
(#lua-match? @_string "^r.*") (#lua-match? @_string "^r.*")
(#set! injection.language "regex")) (#set! injection.language "regex"))
@ -11,4 +14,4 @@
(#set! injection.language "bash")) (#set! injection.language "bash"))
((comment) @injection.content ((comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))

View file

@ -7,10 +7,16 @@
; Imports ; Imports
(aliased_import (aliased_import
alias: (python_identifier) @local.definition.import) alias: (python_identifier) @local.definition.import)
(import_statement (import_statement
name: (dotted_name ((python_identifier) @local.definition.import))) name:
(dotted_name
((python_identifier) @local.definition.import)))
(import_from_statement (import_from_statement
name: (dotted_name ((python_identifier) @local.definition.import))) name:
(dotted_name
((python_identifier) @local.definition.import)))
; Function with parameters, defines parameters ; Function with parameters, defines parameters
(parameters (parameters
@ -38,58 +44,80 @@
; Function defines function and scope ; Function defines function and scope
((python_function_definition ((python_function_definition
name: (python_identifier) @local.definition.function) @local.scope name: (python_identifier) @local.definition.function) @local.scope
(#set! definition.function.scope "parent")) (#set! definition.function.scope "parent"))
(function_definition (identifier) @local.definition.function) (function_definition
(identifier) @local.definition.function)
(anonymous_python_function (identifier) @local.definition.function) (anonymous_python_function
(identifier) @local.definition.function)
;;; Loops ; Loops
; not a scope! ; not a scope!
(for_statement (for_statement
left: (pattern_list left:
(python_identifier) @local.definition.var)) (pattern_list
(python_identifier) @local.definition.var))
(for_statement (for_statement
left: (tuple_pattern left:
(python_identifier) @local.definition.var)) (tuple_pattern
(python_identifier) @local.definition.var))
(for_statement (for_statement
left: (python_identifier) @local.definition.var) left: (python_identifier) @local.definition.var)
; not a scope! ; not a scope!
;(while_statement) @local.scope ;(while_statement) @local.scope
; for in list comprehension ; for in list comprehension
(for_in_clause (for_in_clause
left: (python_identifier) @local.definition.var) left: (python_identifier) @local.definition.var)
(for_in_clause (for_in_clause
left: (tuple_pattern left:
(python_identifier) @local.definition.var)) (tuple_pattern
(python_identifier) @local.definition.var))
(for_in_clause (for_in_clause
left: (pattern_list left:
(python_identifier) @local.definition.var)) (pattern_list
(python_identifier) @local.definition.var))
(dictionary_comprehension) @local.scope (dictionary_comprehension) @local.scope
(list_comprehension) @local.scope (list_comprehension) @local.scope
(set_comprehension) @local.scope (set_comprehension) @local.scope
;;; Assignments ; Assignments
(assignment
left: (python_identifier) @local.definition.var)
(assignment (assignment
left: (python_identifier) @local.definition.var) left:
(pattern_list
(python_identifier) @local.definition.var))
(assignment (assignment
left: (pattern_list left:
(python_identifier) @local.definition.var)) (tuple_pattern
(assignment (python_identifier) @local.definition.var))
left: (tuple_pattern
(python_identifier) @local.definition.var))
(assignment (assignment
left: (attribute left:
(python_identifier) (attribute
(python_identifier) @local.definition.field)) (python_identifier)
(python_identifier) @local.definition.field))
(variable_assignment (identifier) operator: [ "=" "?=" "??=" ":=" ] @local.definition.var) (variable_assignment
(identifier)
operator:
[
"="
"?="
"??="
":="
] @local.definition.var)
; Walrus operator x := 1 ; Walrus operator x := 1
(named_expression (named_expression

View file

@ -1,6 +1,7 @@
(object_id) @variable (object_id) @variable
(string) @string (string) @string
(escape_sequence) @string.escape (escape_sequence) @string.escape
(comment) @comment @spell (comment) @comment @spell
@ -15,30 +16,50 @@
(decorator) @attribute (decorator) @attribute
(property_definition (property_name) @property) (property_definition
(property_name) @property)
(object) @type (object) @type
(signal_binding (signal_name) @function.builtin) (signal_binding
(signal_binding (function (identifier)) @function) (signal_name) @function.builtin)
(signal_binding "swapped" @keyword)
(styles_list "styles" @function.macro) (signal_binding
(layout_definition "layout" @function.macro) (function
(identifier)) @function)
(gettext_string "_" @function.builtin) (signal_binding
"swapped" @keyword)
(menu_definition "menu" @keyword) (styles_list
(menu_section "section" @keyword) "styles" @function.macro)
(menu_item "item" @function.macro)
(template_definition (template_name_qualifier) @type.qualifier) (layout_definition
"layout" @function.macro)
(import_statement (gobject_library) @module) (gettext_string
"_" @function.builtin)
(import_statement (version_number) @number.float) (menu_definition
"menu" @keyword)
(menu_section
"section" @keyword)
(menu_item
"item" @function.macro)
(template_definition
(template_name_qualifier) @type.qualifier)
(import_statement
(gobject_library) @module)
(import_statement
(version_number) @number.float)
(float) @number.float (float) @number.float
(number) @number (number) @number
[ [

View file

@ -1,21 +1,21 @@
[ [
(for_statement) (for_statement)
(if_statement) (if_statement)
(while_statement) (while_statement)
(do_statement) (do_statement)
(switch_statement) (switch_statement)
(case_statement) (case_statement)
(function_definition) (function_definition)
(struct_specifier) (struct_specifier)
(enum_specifier) (enum_specifier)
(comment) (comment)
(preproc_if) (preproc_if)
(preproc_elif) (preproc_elif)
(preproc_else) (preproc_else)
(preproc_ifdef) (preproc_ifdef)
(preproc_function_def) (preproc_function_def)
(initializer_list) (initializer_list)
(gnu_asm_expression) (gnu_asm_expression)
] @fold ] @fold
(compound_statement (compound_statement

View file

@ -1,6 +1,9 @@
; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration. ; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration.
((identifier) @variable (#set! "priority" 95)) ((identifier) @variable
(preproc_def (preproc_arg) @variable) (#set! "priority" 95))
(preproc_def
(preproc_arg) @variable)
[ [
"default" "default"
@ -17,7 +20,10 @@
"sizeof" "sizeof"
"offsetof" "offsetof"
] @keyword.operator ] @keyword.operator
(alignof_expression . _ @keyword.operator)
(alignof_expression
.
_ @keyword.operator)
"return" @keyword.return "return" @keyword.return
@ -30,10 +36,10 @@
] @keyword.repeat ] @keyword.repeat
[ [
"if" "if"
"else" "else"
"case" "case"
"switch" "switch"
] @keyword.conditional ] @keyword.conditional
[ [
@ -52,42 +58,48 @@
"#include" @keyword.import "#include" @keyword.import
[ ";" ":" "," "::" ] @punctuation.delimiter [
";"
":"
","
"::"
] @punctuation.delimiter
"..." @punctuation.special "..." @punctuation.special
[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket [
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
[ [
"=" "="
"-" "-"
"*" "*"
"/" "/"
"+" "+"
"%" "%"
"~" "~"
"|" "|"
"&" "&"
"^" "^"
"<<" "<<"
">>" ">>"
"->" "->"
"." "."
"<" "<"
"<=" "<="
">=" ">="
">" ">"
"==" "=="
"!=" "!="
"!" "!"
"&&" "&&"
"||" "||"
"-=" "-="
"+=" "+="
"*=" "*="
@ -102,42 +114,54 @@
"++" "++"
] @operator ] @operator
;; Make sure the comma operator is given a highlight group after the comma ; Make sure the comma operator is given a highlight group after the comma
;; punctuator so the operator is highlighted properly. ; punctuator so the operator is highlighted properly.
(comma_expression [ "," ] @operator) (comma_expression
"," @operator)
[ [
(true) (true)
(false) (false)
] @boolean ] @boolean
(conditional_expression [ "?" ":" ] @keyword.conditional.ternary) (conditional_expression
[
"?"
":"
] @keyword.conditional.ternary)
(string_literal) @string (string_literal) @string
(system_lib_string) @string (system_lib_string) @string
(escape_sequence) @string.escape (escape_sequence) @string.escape
(null) @constant.builtin (null) @constant.builtin
(number_literal) @number (number_literal) @number
(char_literal) @character (char_literal) @character
((preproc_arg) @function.macro (#set! "priority" 90)) ((preproc_arg) @function.macro
(#set! "priority" 90))
(preproc_defined) @function.macro (preproc_defined) @function.macro
((field_expression ((field_expression
(field_identifier) @property) @_parent (field_identifier) @property) @_parent
(#not-has-parent? @_parent template_method function_declarator call_expression)) (#not-has-parent? @_parent template_method function_declarator call_expression))
(field_designator) @property (field_designator) @property
((field_identifier) @property ((field_identifier) @property
(#has-ancestor? @property field_declaration) (#has-ancestor? @property field_declaration)
(#not-has-ancestor? @property function_declarator)) (#not-has-ancestor? @property function_declarator))
(statement_identifier) @label (statement_identifier) @label
[ [
(type_identifier) (type_identifier)
(type_descriptor) (type_descriptor)
] @type ] @type
(storage_class_specifier) @keyword.storage (storage_class_specifier) @keyword.storage
@ -156,14 +180,20 @@
(primitive_type) @type.builtin (primitive_type) @type.builtin
(sized_type_specifier _ @type.builtin type: _?) (sized_type_specifier
_ @type.builtin
type: _?)
((identifier) @constant ((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
(preproc_def (preproc_arg) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) (#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
(preproc_def
(preproc_arg) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
(enumerator (enumerator
name: (identifier) @constant) name: (identifier) @constant)
(case_statement (case_statement
value: (identifier) @constant) value: (identifier) @constant)
@ -181,7 +211,9 @@
"__clang_wide_literal_encoding__" "__clang_wide_literal_encoding__"
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__" "__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
"__VA_ARGS__" "__VA_OPT__")) "__VA_ARGS__" "__VA_OPT__"))
(preproc_def (preproc_arg) @constant.builtin
(preproc_def
(preproc_arg) @constant.builtin
; format-ignore ; format-ignore
(#any-of? @constant.builtin (#any-of? @constant.builtin
"stderr" "stdin" "stdout" "stderr" "stdin" "stdout"
@ -197,21 +229,26 @@
"__VA_ARGS__" "__VA_OPT__")) "__VA_ARGS__" "__VA_OPT__"))
(attribute_specifier (attribute_specifier
(argument_list (identifier) @variable.builtin)) (argument_list
(identifier) @variable.builtin))
((attribute_specifier ((attribute_specifier
(argument_list (call_expression (argument_list
function: (identifier) @variable.builtin)))) (call_expression
function: (identifier) @variable.builtin))))
((call_expression ((call_expression
function: (identifier) @function.builtin) function: (identifier) @function.builtin)
(#lua-match? @function.builtin "^__builtin_")) (#lua-match? @function.builtin "^__builtin_"))
((call_expression ((call_expression
function: (identifier) @function.builtin) function: (identifier) @function.builtin)
(#has-ancestor? @function.builtin attribute_specifier)) (#has-ancestor? @function.builtin attribute_specifier))
;; Preproc def / undef ; Preproc def / undef
(preproc_def (preproc_def
name: (_) @constant) name: (_) @constant)
(preproc_call (preproc_call
directive: (preproc_directive) @_u directive: (preproc_directive) @_u
argument: (_) @constant argument: (_) @constant
@ -219,15 +256,21 @@
(call_expression (call_expression
function: (identifier) @function.call) function: (identifier) @function.call)
(call_expression (call_expression
function: (field_expression function:
field: (field_identifier) @function.call)) (field_expression
field: (field_identifier) @function.call))
(function_declarator (function_declarator
declarator: (identifier) @function) declarator: (identifier) @function)
(function_declarator (function_declarator
declarator: (parenthesized_declarator declarator:
(pointer_declarator (parenthesized_declarator
declarator: (field_identifier) @function))) (pointer_declarator
declarator: (field_identifier) @function)))
(preproc_function_def (preproc_function_def
name: (identifier) @function.macro) name: (identifier) @function.macro)
@ -236,7 +279,7 @@
((comment) @comment.documentation ((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
;; Parameters ; Parameters
(parameter_declaration (parameter_declaration
declarator: (identifier) @variable.parameter) declarator: (identifier) @variable.parameter)
@ -268,8 +311,8 @@
; declarator: _ ; declarator: _
; (declaration ; (declaration
; declarator: (pointer_declarator) @variable.parameter)) ; declarator: (pointer_declarator) @variable.parameter))
(preproc_params
(preproc_params (identifier) @variable.parameter) (identifier) @variable.parameter)
[ [
"__attribute__" "__attribute__"

View file

@ -1,5 +1,5 @@
[ [
(compound_statement) (compound_statement)
(field_declaration_list) (field_declaration_list)
(case_statement) (case_statement)
(enumerator_list) (enumerator_list)
@ -7,56 +7,62 @@
(initializer_list) (initializer_list)
(init_declarator) (init_declarator)
] @indent.begin ] @indent.begin
; With current indent logic, if we capture expression_statement with @indent.begin ; With current indent logic, if we capture expression_statement with @indent.begin
; It will be affected by _parent_ node with error subnodes deep down the tree ; It will be affected by _parent_ node with error subnodes deep down the tree
; So narrow indent capture to check for error inside expression statement only, ; So narrow indent capture to check for error inside expression statement only,
(expression_statement (expression_statement
(_) @indent.begin (_) @indent.begin
";" @indent.end) ";" @indent.end)
(ERROR (ERROR
"for" "(" @indent.begin ";" ";" ")" @indent.end) "for"
"(" @indent.begin
";"
";"
")" @indent.end)
((for_statement ((for_statement
body: (_) @_body) @indent.begin body: (_) @_body) @indent.begin
(#not-has-type? @_body compound_statement)) (#not-has-type? @_body compound_statement))
(while_statement (while_statement
condition: (_) @indent.begin) condition: (_) @indent.begin)
((while_statement ((while_statement
body: (_) @_body) @indent.begin body: (_) @_body) @indent.begin
(#not-has-type? @_body compound_statement)) (#not-has-type? @_body compound_statement))
( ((if_statement)
(if_statement)
. .
(ERROR "else" @indent.begin)) (ERROR
"else" @indent.begin))
(if_statement (if_statement
condition: (_) @indent.begin) condition: (_) @indent.begin)
;; Supports if without braces (but not both if-else without braces) ; Supports if without braces (but not both if-else without braces)
((if_statement ((if_statement
consequence: consequence:
(_ ";" @indent.end) @_consequence (_
(#not-has-type? @_consequence compound_statement) ";" @indent.end) @_consequence
(#not-has-type? @_consequence compound_statement)
alternative: alternative:
(else_clause (else_clause
"else" @indent.branch "else" @indent.branch
[ [
(if_statement (compound_statement) @indent.dedent)? @indent.dedent (if_statement
(compound_statement) @indent.dedent)? @indent.dedent
(compound_statement)? @indent.dedent (compound_statement)? @indent.dedent
(_)? @indent.dedent (_)? @indent.dedent
] ])?) @indent.begin)
)?
) @indent.begin)
(else_clause (_ . "{" @indent.branch)) (else_clause
(_
.
"{" @indent.branch))
(compound_statement
(compound_statement "}" @indent.end) "}" @indent.end)
[ [
")" ")"
@ -79,12 +85,16 @@
(string_literal) (string_literal)
] @indent.ignore ] @indent.ignore
((ERROR (parameter_declaration)) @indent.align ((ERROR
(#set! indent.open_delimiter "(") (parameter_declaration)) @indent.align
(#set! indent.close_delimiter ")")) (#set! indent.open_delimiter "(")
([(argument_list) (parameter_list)] @indent.align (#set! indent.close_delimiter ")"))
([
(argument_list)
(parameter_list)
] @indent.align
(#set! indent.open_delimiter "(") (#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")) (#set! indent.close_delimiter ")"))
(comment) @indent.auto (comment) @indent.auto

View file

@ -1,8 +1,8 @@
((preproc_arg) @injection.content ((preproc_arg) @injection.content
(#set! injection.language "c")) (#set! injection.language "c"))
((comment) @injection.content ((comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))
((comment) @injection.content ((comment) @injection.content
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c") (#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
@ -14,8 +14,11 @@
((call_expression ((call_expression
function: (identifier) @_function function: (identifier) @_function
arguments: (argument_list arguments:
. (string_literal (string_content) @injection.content))) (argument_list
.
(string_literal
(string_content) @injection.content)))
; format-ignore ; format-ignore
(#any-of? @_function (#any-of? @_function
"printf" "printf_s" "printf" "printf_s"
@ -29,12 +32,16 @@
"cscanf" "_cscanf" "cscanf" "_cscanf"
"printw" "printw"
"scanw") "scanw")
(#set! injection.language "printf")) (#set! injection.language "printf"))
((call_expression ((call_expression
function: (identifier) @_function function: (identifier) @_function
arguments: (argument_list arguments:
(_) . (string_literal (string_content) @injection.content))) (argument_list
(_)
.
(string_literal
(string_content) @injection.content)))
; format-ignore ; format-ignore
(#any-of? @_function (#any-of? @_function
"fprintf" "fprintf_s" "fprintf" "fprintf_s"
@ -57,12 +64,18 @@
"vw_printw" "vwprintw" "vw_printw" "vwprintw"
"wscanw" "wscanw"
"vw_scanw" "vwscanw") "vw_scanw" "vwscanw")
(#set! injection.language "printf")) (#set! injection.language "printf"))
((call_expression ((call_expression
function: (identifier) @_function function: (identifier) @_function
arguments: (argument_list arguments:
(_) . (_) . (string_literal (string_content) @injection.content))) (argument_list
(_)
.
(_)
.
(string_literal
(string_content) @injection.content)))
; format-ignore ; format-ignore
(#any-of? @_function (#any-of? @_function
"sprintf_s" "sprintf_s"
@ -75,15 +88,22 @@
"vsnwprintf_s" "vsnwprintf_s"
"mvprintw" "mvprintw"
"mvscanw") "mvscanw")
(#set! injection.language "printf")) (#set! injection.language "printf"))
((call_expression ((call_expression
function: (identifier) @_function function: (identifier) @_function
arguments: (argument_list arguments:
(_) . (_) . (_) . (string_literal (string_content) @injection.content))) (argument_list
(#any-of? @_function "mvwprintw" (_)
"mvwscanw") .
(#set! injection.language "printf")) (_)
.
(_)
.
(string_literal
(string_content) @injection.content)))
(#any-of? @_function "mvwprintw" "mvwscanw")
(#set! injection.language "printf"))
; TODO: add when asm is added ; TODO: add when asm is added
; (gnu_asm_expression assembly_code: (string_literal) @injection.content ; (gnu_asm_expression assembly_code: (string_literal) @injection.content

View file

@ -1,53 +1,67 @@
;; Functions definitions ; Functions definitions
(function_declarator (function_declarator
declarator: (identifier) @local.definition.function) declarator: (identifier) @local.definition.function)
(preproc_function_def (preproc_function_def
name: (identifier) @local.definition.macro) @local.scope name: (identifier) @local.definition.macro) @local.scope
(preproc_def (preproc_def
name: (identifier) @local.definition.macro) name: (identifier) @local.definition.macro)
(pointer_declarator (pointer_declarator
declarator: (identifier) @local.definition.var) declarator: (identifier) @local.definition.var)
(parameter_declaration (parameter_declaration
declarator: (identifier) @local.definition.parameter) declarator: (identifier) @local.definition.parameter)
(init_declarator (init_declarator
declarator: (identifier) @local.definition.var) declarator: (identifier) @local.definition.var)
(array_declarator (array_declarator
declarator: (identifier) @local.definition.var) declarator: (identifier) @local.definition.var)
(declaration (declaration
declarator: (identifier) @local.definition.var) declarator: (identifier) @local.definition.var)
(enum_specifier (enum_specifier
name: (_) @local.definition.type name: (_) @local.definition.type
(enumerator_list (enumerator_list
(enumerator name: (identifier) @local.definition.var))) (enumerator
name: (identifier) @local.definition.var)))
;; Type / Struct / Enum ; Type / Struct / Enum
(field_declaration (field_declaration
declarator: (field_identifier) @local.definition.field) declarator: (field_identifier) @local.definition.field)
(type_definition (type_definition
declarator: (type_identifier) @local.definition.type) declarator: (type_identifier) @local.definition.type)
(struct_specifier (struct_specifier
name: (type_identifier) @local.definition.type) name: (type_identifier) @local.definition.type)
;; goto ; goto
(labeled_statement (statement_identifier) @local.definition) (labeled_statement
(statement_identifier) @local.definition)
;; References ; References
(identifier) @local.reference (identifier) @local.reference
((field_identifier) @local.reference ((field_identifier) @local.reference
(#set! reference.kind "field")) (#set! reference.kind "field"))
((type_identifier) @local.reference ((type_identifier) @local.reference
(#set! reference.kind "type")) (#set! reference.kind "type"))
(goto_statement (statement_identifier) @local.reference) (goto_statement
(statement_identifier) @local.reference)
;; Scope ; Scope
[ [
(for_statement) (for_statement)
(if_statement) (if_statement)
(while_statement) (while_statement)
(translation_unit) (translation_unit)
(function_definition) (function_definition)
(compound_statement) ; a block in curly braces (compound_statement) ; a block in curly braces
(struct_specifier) (struct_specifier)
] @local.scope ] @local.scope

View file

@ -1,15 +1,10 @@
body: [ body:
(declaration_list) [
(switch_body) (declaration_list)
(enum_member_declaration_list) (switch_body)
] @fold (enum_member_declaration_list)
] @fold
accessors: [ accessors: (accessor_list) @fold
(accessor_list) initializer: (initializer_expression) @fold
] @fold
initializer: [
(initializer_expression)
] @fold
(block) @fold (block) @fold

View file

@ -26,18 +26,23 @@
name: (identifier) @function.method.call)) name: (identifier) @function.method.call))
(invocation_expression (invocation_expression
function: (conditional_access_expression function:
(member_binding_expression (conditional_access_expression
name: (identifier) @function.method.call))) (member_binding_expression
name: (identifier) @function.method.call)))
(namespace_declaration (namespace_declaration
name: [(qualified_name) (identifier)] @module) name:
[
(qualified_name)
(identifier)
] @module)
(qualified_name (qualified_name
(identifier) @type) (identifier) @type)
(invocation_expression (invocation_expression
(identifier) @function.method.call) (identifier) @function.method.call)
(field_declaration (field_declaration
(variable_declaration (variable_declaration
@ -50,29 +55,29 @@
(parameter_list (parameter_list
(parameter (parameter
name: (identifier) @variable.parameter)) name: (identifier) @variable.parameter))
(parameter_list (parameter_list
(parameter (parameter
type: (identifier) @type)) type: (identifier) @type))
(integer_literal) @number (integer_literal) @number
(real_literal) @number.float (real_literal) @number.float
(null_literal) @constant.builtin (null_literal) @constant.builtin
(character_literal) @character (character_literal) @character
[ [
(string_literal) (string_literal)
(verbatim_string_literal) (verbatim_string_literal)
(interpolated_string_expression) (interpolated_string_expression)
] @string ] @string
(boolean_literal) @boolean (boolean_literal) @boolean
[ (predefined_type) @type.builtin
(predefined_type)
] @type.builtin
(implicit_type) @keyword (implicit_type) @keyword
@ -83,6 +88,7 @@
((comment) @comment.documentation ((comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]")) (#lua-match? @comment.documentation "^///[^/]"))
((comment) @comment.documentation ((comment) @comment.documentation
(#lua-match? @comment.documentation "^///$")) (#lua-match? @comment.documentation "^///$"))
@ -90,7 +96,8 @@
(identifier) @type) (identifier) @type)
(using_directive (using_directive
(name_equals (identifier) @type.definition)) (name_equals
(identifier) @type.definition))
(property_declaration (property_declaration
name: (identifier) @property) name: (identifier) @property)
@ -106,20 +113,25 @@
(interface_declaration (interface_declaration
name: (identifier) @type) name: (identifier) @type)
(class_declaration (class_declaration
name: (identifier) @type) name: (identifier) @type)
(record_declaration (record_declaration
name: (identifier) @type) name: (identifier) @type)
(enum_declaration (enum_declaration
name: (identifier) @type) name: (identifier) @type)
(constructor_declaration (constructor_declaration
name: (identifier) @constructor) name: (identifier) @constructor)
(constructor_initializer [
"base" @constructor (constructor_initializer
]) "base" @constructor)
(variable_declaration (variable_declaration
(identifier) @type) (identifier) @type)
(object_creation_expression (object_creation_expression
(identifier) @type) (identifier) @type)
@ -142,19 +154,23 @@
(object_creation_expression (object_creation_expression
(generic_name (generic_name
(identifier) @type)) (identifier) @type))
(property_declaration (property_declaration
(generic_name (generic_name
(identifier) @type)) (identifier) @type))
(_ (_
type: (generic_name type:
(identifier) @type)) (generic_name
(identifier) @type))
; Generic Method invocation with generic type ; Generic Method invocation with generic type
(invocation_expression (invocation_expression
function: (generic_name function:
. (identifier) @function.method.call)) (generic_name
.
(identifier) @function.method.call))
(invocation_expression (invocation_expression
(member_access_expression (member_access_expression
@ -165,7 +181,7 @@
(identifier) @type) (identifier) @type)
(type_argument_list (type_argument_list
(identifier) @type) (identifier) @type)
(type_parameter_list (type_parameter_list
(type_parameter) @type) (type_parameter) @type)
@ -174,7 +190,7 @@
target: (identifier) @type) target: (identifier) @type)
(attribute (attribute
name: (identifier) @attribute) name: (identifier) @attribute)
(for_each_statement (for_each_statement
type: (identifier) @type) type: (identifier) @type)
@ -197,180 +213,194 @@
(identifier) @variable.parameter) (identifier) @variable.parameter)
(warning_directive) @comment.warning (warning_directive) @comment.warning
(error_directive) @keyword.exception (error_directive) @keyword.exception
(define_directive (define_directive
(identifier) @constant) @constant.macro (identifier) @constant) @constant.macro
(undef_directive (undef_directive
(identifier) @constant) @constant.macro (identifier) @constant) @constant.macro
(line_directive) @constant.macro (line_directive) @constant.macro
(line_directive (line_directive
(preproc_integer_literal) @constant (preproc_integer_literal) @constant
(preproc_string_literal)? @string) (preproc_string_literal)? @string)
(pragma_directive (pragma_directive
(identifier) @constant) @constant.macro (identifier) @constant) @constant.macro
(pragma_directive (pragma_directive
(preproc_string_literal) @string) @constant.macro (preproc_string_literal) @string) @constant.macro
[ [
(nullable_directive) (nullable_directive)
(region_directive) (region_directive)
(endregion_directive) (endregion_directive)
] @constant.macro ] @constant.macro
[ [
"if" "if"
"else" "else"
"switch" "switch"
"break" "break"
"case" "case"
"when" "when"
(if_directive) (if_directive)
(elif_directive) (elif_directive)
(else_directive) (else_directive)
(endif_directive) (endif_directive)
] @keyword.conditional ] @keyword.conditional
(if_directive (if_directive
(identifier) @constant) (identifier) @constant)
(elif_directive (elif_directive
(identifier) @constant) (identifier) @constant)
[ [
"while" "while"
"for" "for"
"do" "do"
"continue" "continue"
"goto" "goto"
"foreach" "foreach"
] @keyword.repeat ] @keyword.repeat
[ [
"try" "try"
"catch" "catch"
"throw" "throw"
"finally" "finally"
] @keyword.exception ] @keyword.exception
[ [
"+" "+"
"?" "?"
":" ":"
"++" "++"
"-" "-"
"--" "--"
"&" "&"
"&&" "&&"
"|" "|"
"||" "||"
"!" "!"
"!=" "!="
"==" "=="
"*" "*"
"/" "/"
"%" "%"
"<" "<"
"<=" "<="
">" ">"
">=" ">="
"=" "="
"-=" "-="
"+=" "+="
"*=" "*="
"/=" "/="
"%=" "%="
"^" "^"
"^=" "^="
"&=" "&="
"|=" "|="
"~" "~"
">>" ">>"
">>>" ">>>"
"<<" "<<"
"<<=" "<<="
">>=" ">>="
">>>=" ">>>="
"=>" "=>"
"??" "??"
"??=" "??="
] @operator ] @operator
[ [
";" ";"
"." "."
"," ","
":" ":"
] @punctuation.delimiter ] @punctuation.delimiter
(conditional_expression ["?" ":"] @keyword.conditional.ternary) (conditional_expression
[
"?"
":"
] @keyword.conditional.ternary)
[ [
"[" "["
"]" "]"
"{" "{"
"}" "}"
"(" "("
")" ")"
] @punctuation.bracket ] @punctuation.bracket
(type_argument_list ["<" ">"] @punctuation.bracket) (type_argument_list
[
"<"
">"
] @punctuation.bracket)
[ [
(this_expression) (this_expression)
(base_expression) (base_expression)
] @variable.builtin ] @variable.builtin
[ [
"using" "using"
"as" "as"
] @keyword.import ] @keyword.import
(alias_qualified_name (alias_qualified_name
(identifier "global") @keyword.import) (identifier
"global") @keyword.import)
[ [
"with" "with"
"new" "new"
"typeof" "typeof"
"sizeof" "sizeof"
"is" "is"
"and" "and"
"or" "or"
"not" "not"
"stackalloc" "stackalloc"
"in" "in"
"out" "out"
"ref" "ref"
] @keyword.operator ] @keyword.operator
[ [
"lock" "lock"
"params" "params"
"operator" "operator"
"default" "default"
"implicit" "implicit"
"explicit" "explicit"
"override" "override"
"class" "class"
"delegate" "delegate"
"enum" "enum"
"interface" "interface"
"namespace" "namespace"
"struct" "struct"
"get" "get"
"set" "set"
"init" "init"
"where" "where"
"record" "record"
"event" "event"
"add" "add"
"remove" "remove"
"checked" "checked"
"unchecked" "unchecked"
"fixed" "fixed"
"alias" "alias"
] @keyword ] @keyword
[ [
@ -379,39 +409,40 @@
] @keyword.coroutine ] @keyword.coroutine
[ [
"const" "const"
"extern" "extern"
"readonly" "readonly"
"static" "static"
"volatile" "volatile"
"required" "required"
] @keyword.storage ] @keyword.storage
[ [
"abstract" "abstract"
"private" "private"
"protected" "protected"
"internal" "internal"
"public" "public"
"partial" "partial"
"sealed" "sealed"
"virtual" "virtual"
] @type.qualifier ] @type.qualifier
(parameter_modifier) @operator (parameter_modifier) @operator
(query_expression (query_expression
(_ [ (_
"from" [
"orderby" "from"
"select" "orderby"
"group" "select"
"by" "group"
"ascending" "by"
"descending" "ascending"
"equals" "descending"
"let" "equals"
] @keyword)) "let"
] @keyword))
[ [
"return" "return"

View file

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

View file

@ -1,6 +1,7 @@
;; Definitions ; Definitions
(variable_declarator (variable_declarator
. (identifier) @local.definition.var) .
(identifier) @local.definition.var)
(variable_declarator (variable_declarator
(tuple_pattern (tuple_pattern
@ -13,8 +14,9 @@
left: (identifier) @local.definition.var) left: (identifier) @local.definition.var)
(for_each_statement (for_each_statement
left: (tuple_pattern left:
(identifier) @local.definition.var)) (tuple_pattern
(identifier) @local.definition.var))
(parameter (parameter
(identifier) @local.definition.parameter) (identifier) @local.definition.parameter)
@ -34,8 +36,8 @@
(class_declaration (class_declaration
name: (identifier) @local.definition) name: (identifier) @local.definition)
;; References ; References
(identifier) @local.reference (identifier) @local.reference
;; Scope ; Scope
(block) @local.scope (block) @local.scope

View file

@ -5,20 +5,16 @@
(enum_item) (enum_item)
(impl_item) (impl_item)
(type_item) (type_item)
(use_declaration) (use_declaration)
(let_declaration) (let_declaration)
(namespace_definition) (namespace_definition)
(arguments) (arguments)
(implicit_arguments) (implicit_arguments)
(tuple_type) (tuple_type)
(import_statement) (import_statement)
(attribute_statement) (attribute_statement)
(with_statement) (with_statement)
(if_statement) (if_statement)
(function_definition) (function_definition)
(struct_definition) (struct_definition)
(loop_expression) (loop_expression)
@ -26,6 +22,5 @@
(match_expression) (match_expression)
(call_expression) (call_expression)
(tuple_expression) (tuple_expression)
(attribute_item) (attribute_item)
] @fold ] @fold

View file

@ -1,13 +1,18 @@
; Preproc ; Preproc
[ [
"%builtins" "%builtins"
"%lang" "%lang"
] @keyword.directive ] @keyword.directive
; Includes ; Includes
(import_statement
(import_statement [ "from" "import" ] @keyword.import module_name: (dotted_name (identifier) @module . )) [
"from"
"import"
] @keyword.import
module_name:
(dotted_name
(identifier) @module .))
[ [
"as" "as"
@ -16,41 +21,42 @@
] @keyword.import ] @keyword.import
; Variables ; Variables
(identifier) @variable (identifier) @variable
; Namespaces ; Namespaces
(namespace_definition
(namespace_definition (identifier) @module) (identifier) @module)
(mod_item (mod_item
name: (identifier) @module) name: (identifier) @module)
(use_list (self) @module) (use_list
(self) @module)
(scoped_use_list (self) @module) (scoped_use_list
(self) @module)
(scoped_identifier (scoped_identifier
path: (identifier) @module) path: (identifier) @module)
(scoped_identifier (scoped_identifier
(scoped_identifier (scoped_identifier
name: (identifier) @module)) name: (identifier) @module))
(scoped_type_identifier (scoped_type_identifier
path: (identifier) @module) path: (identifier) @module)
((scoped_identifier ((scoped_identifier
path: (identifier) @type) path: (identifier) @type)
(#lua-match? @type "^[A-Z]")) (#lua-match? @type "^[A-Z]"))
((scoped_identifier ((scoped_identifier
name: (identifier) @type) name: (identifier) @type)
(#lua-match? @type "^[A-Z]")) (#lua-match? @type "^[A-Z]"))
((scoped_identifier ((scoped_identifier
name: (identifier) @constant) name: (identifier) @constant)
(#lua-match? @constant "^[A-Z][A-Z%d_]*$")) (#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
((scoped_identifier ((scoped_identifier
path: (identifier) @type path: (identifier) @type
@ -68,17 +74,25 @@
path: (identifier) @module) path: (identifier) @module)
(scoped_use_list (scoped_use_list
path: (scoped_identifier path:
(identifier) @module)) (scoped_identifier
(identifier) @module))
(use_list (scoped_identifier (identifier) @module . (_))) (use_list
(scoped_identifier
(identifier) @module
.
(_)))
(use_list (identifier) @type (#lua-match? @type "^[A-Z]")) (use_list
(identifier) @type
(#lua-match? @type "^[A-Z]"))
(use_as_clause alias: (identifier) @type (#lua-match? @type "^[A-Z]")) (use_as_clause
alias: (identifier) @type
(#lua-match? @type "^[A-Z]"))
; Keywords ; Keywords
[ [
; 0.x ; 0.x
"using" "using"
@ -96,7 +110,6 @@
"with" "with"
"call" "call"
"nondet" "nondet"
; 1.0 ; 1.0
"type" "type"
"impl" "impl"
@ -133,9 +146,7 @@
"match" "match"
] @keyword.conditional ] @keyword.conditional
[ "loop" @keyword.repeat
"loop"
] @keyword.repeat
[ [
"assert" "assert"
@ -144,33 +155,52 @@
] @keyword.exception ] @keyword.exception
; Fields ; Fields
(implicit_arguments
(typed_identifier
(identifier) @variable.member))
(implicit_arguments (typed_identifier (identifier) @variable.member)) (member_expression
"."
(identifier) @variable.member)
(member_expression "." (identifier) @variable.member) (call_expression
(assignment_expression
left: (identifier) @variable.member))
(call_expression (assignment_expression left: (identifier) @variable.member)) (tuple_expression
(assignment_expression
(tuple_expression (assignment_expression left: (identifier) @variable.member)) left: (identifier) @variable.member))
(field_identifier) @variable.member (field_identifier) @variable.member
(shorthand_field_initializer (identifier) @variable.member) (shorthand_field_initializer
(identifier) @variable.member)
; Parameters ; Parameters
(arguments
(typed_identifier
(identifier) @variable.parameter))
(arguments (typed_identifier (identifier) @variable.parameter)) (call_expression
(tuple_expression
(assignment_expression
left: (identifier) @variable.parameter)))
(call_expression (tuple_expression (assignment_expression left: (identifier) @variable.parameter))) (return_type
(tuple_type
(named_type
.
(identifier) @variable.parameter)))
(return_type (tuple_type (named_type . (identifier) @variable.parameter))) (parameter
(identifier) @variable.parameter)
(parameter (identifier) @variable.parameter)
; Builtins ; Builtins
(builtin_directive
(identifier) @variable.builtin)
(builtin_directive (identifier) @variable.builtin) (lang_directive
(lang_directive (identifier) @variable.builtin) (identifier) @variable.builtin)
[ [
"ap" "ap"
@ -179,32 +209,45 @@
] @variable.builtin ] @variable.builtin
; Functions ; Functions
(function_definition
"func"
(identifier) @function)
(function_definition "func" (identifier) @function) (function_definition
(function_definition "fn" (identifier) @function) "fn"
(function_signature "fn" (identifier) @function) (identifier) @function)
(extern_function_statement (identifier) @function)
(function_signature
"fn"
(identifier) @function)
(extern_function_statement
(identifier) @function)
(call_expression (call_expression
function: (identifier) @function.call) function: (identifier) @function.call)
(call_expression (call_expression
function: (scoped_identifier function:
(identifier) @function.call .)) (scoped_identifier
(identifier) @function.call .))
(call_expression (call_expression
function: (field_expression function:
field: (field_identifier) @function.call)) (field_expression
field: (field_identifier) @function.call))
[ "jmp" @function.builtin
"jmp"
] @function.builtin
; Types ; Types
(struct_definition
.
(identifier) @type
(typed_identifier
(identifier) @variable.member)?)
(struct_definition . (identifier) @type (typed_identifier (identifier) @variable.member)?) (named_type
(identifier) @type .)
(named_type (identifier) @type .)
[ [
(builtin_type) (builtin_type)
@ -217,7 +260,6 @@
(type_identifier) @type (type_identifier) @type
; Constants ; Constants
((identifier) @constant ((identifier) @constant
(#lua-match? @constant "^[A-Z_][A-Z0-9_]*$")) (#lua-match? @constant "^[A-Z_][A-Z0-9_]*$"))
@ -225,49 +267,68 @@
name: (identifier) @constant) name: (identifier) @constant)
(call_expression (call_expression
function: (scoped_identifier function:
"::" (scoped_identifier
name: (identifier) @constant) "::"
name: (identifier) @constant)
(#lua-match? @constant "^[A-Z]")) (#lua-match? @constant "^[A-Z]"))
((match_arm ((match_arm
pattern: (match_pattern (identifier) @constant)) pattern:
(#lua-match? @constant "^[A-Z]")) (match_pattern
(identifier) @constant))
(#lua-match? @constant "^[A-Z]"))
((match_arm ((match_arm
pattern: (match_pattern pattern:
(scoped_identifier (match_pattern
name: (identifier) @constant))) (scoped_identifier
(#lua-match? @constant "^[A-Z]")) name: (identifier) @constant)))
(#lua-match? @constant "^[A-Z]"))
((identifier) @constant.builtin ((identifier) @constant.builtin
(#any-of? @constant.builtin "Some" "None" "Ok" "Err")) (#any-of? @constant.builtin "Some" "None" "Ok" "Err"))
; Constructors ; Constructors
(unary_expression
"new"
(call_expression
.
(identifier) @constructor))
(unary_expression "new" (call_expression . (identifier) @constructor)) ((call_expression
.
((call_expression . (identifier) @constructor) (identifier) @constructor)
(#lua-match? @constructor "^%u")) (#lua-match? @constructor "^%u"))
; Attributes ; Attributes
(decorator
"@" @attribute
(identifier) @attribute)
(decorator "@" @attribute (identifier) @attribute) (attribute_item
(identifier) @function.macro)
(attribute_item (identifier) @function.macro) (attribute_item
(scoped_identifier
(attribute_item (scoped_identifier (identifier) @function.macro .)) (identifier) @function.macro .))
; Labels ; Labels
(label
.
(identifier) @label)
(label . (identifier) @label) (inst_jmp_to_label
"jmp"
.
(identifier) @label)
(inst_jmp_to_label "jmp" . (identifier) @label) (inst_jnz_to_label
"jmp"
(inst_jnz_to_label "jmp" . (identifier) @label) .
(identifier) @label)
; Operators ; Operators
[ [
"+" "+"
"-" "-"
@ -307,7 +368,6 @@
] @operator ] @operator
; Literals ; Literals
(number) @number (number) @number
(boolean) @boolean (boolean) @boolean
@ -318,17 +378,41 @@
] @string ] @string
; Punctuation ; Punctuation
(attribute_item
"#" @punctuation.special)
(attribute_item "#" @punctuation.special) [
"."
","
":"
";"
"->"
"=>"
"::"
] @punctuation.delimiter
[ "." "," ":" ";" "->" "=>" "::" ] @punctuation.delimiter [
"{"
"}"
"("
")"
"["
"]"
"%{"
"%}"
] @punctuation.bracket
[ "{" "}" "(" ")" "[" "]" "%{" "%}" ] @punctuation.bracket (type_parameters
[
"<"
">"
] @punctuation.bracket)
(type_parameters [ "<" ">" ] @punctuation.bracket) (type_arguments
[
(type_arguments [ "<" ">" ] @punctuation.bracket) "<"
">"
] @punctuation.bracket)
; Comment ; Comment
(comment) @comment @spell (comment) @comment @spell

View file

@ -18,19 +18,36 @@
(tuple_pattern) (tuple_pattern)
] @indent.begin ] @indent.begin
(import_statement "(") @indent.begin (import_statement
"(") @indent.begin
(block
"}" @indent.end)
(block "}" @indent.end)
(enum_item (enum_item
body: (enum_variant_list "}" @indent.end)) body:
(enum_variant_list
"}" @indent.end))
(match_expression (match_expression
body: (match_block "}" @indent.end)) body:
(match_block
"}" @indent.end))
(mod_item (mod_item
body: (declaration_list "}" @indent.end)) body:
(declaration_list
"}" @indent.end))
(struct_item (struct_item
body: (field_declaration_list "}" @indent.end)) body:
(field_declaration_list
"}" @indent.end))
(trait_item (trait_item
body: (declaration_list "}" @indent.end)) body:
(declaration_list
"}" @indent.end))
[ [
")" ")"

View file

@ -1,3 +1,5 @@
(python_code) @python ((python_code) @injection.content
(#set! injection.language "python"))
(comment) @comment ((comment) @injection.content
(#set! injection.language "comment"))

View file

@ -1,13 +1,13 @@
; References ; References
(identifier) @local.reference (identifier) @local.reference
((type_identifier) @local.reference ((type_identifier) @local.reference
(#set! reference.kind "type")) (#set! reference.kind "type"))
((field_identifier) @local.reference ((field_identifier) @local.reference
(#set! reference.kind "field")) (#set! reference.kind "field"))
; Scopes ; Scopes
[ [
(program) (program)
(block) (block)
@ -16,53 +16,52 @@
(if_expression) (if_expression)
(match_expression) (match_expression)
(match_arm) (match_arm)
(struct_item) (struct_item)
(enum_item) (enum_item)
(impl_item) (impl_item)
] @local.scope ] @local.scope
(use_declaration (use_declaration
argument: (scoped_identifier argument:
name: (identifier) @local.definition.import)) (scoped_identifier
name: (identifier) @local.definition.import))
(use_as_clause (use_as_clause
alias: (identifier) @local.definition.import) alias: (identifier) @local.definition.import)
(use_list (use_list
(identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio}; (identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio};
; Functions ; Functions
(function_definition (function_definition
(identifier) @local.definition.function) (identifier) @local.definition.function)
(function_definition (function_definition
(identifier) @local.definition.method (identifier) @local.definition.method
(parameter (self))) (parameter
(self)))
; Function with parameters, defines parameters ; Function with parameters, defines parameters
(parameter (parameter
[ (identifier) (self) ] @local.definition.parameter) [
(identifier)
(self)
] @local.definition.parameter)
; Types ; Types
(struct_item (struct_item
name: (type_identifier) @local.definition.type) name: (type_identifier) @local.definition.type)
(constrained_type_parameter (constrained_type_parameter
left: (type_identifier) @local.definition.type) ; the P in remove_file<P: AsRef<Path>>(path: P) left: (type_identifier) @local.definition.type) ; the P in remove_file<P: AsRef<Path>>(path: P)
(enum_item (enum_item
name: (type_identifier) @local.definition.type) name: (type_identifier) @local.definition.type)
; Module ; Module
(mod_item
(mod_item
name: (identifier) @local.definition.namespace) name: (identifier) @local.definition.namespace)
; Variables ; Variables
(assignment_expression (assignment_expression
left: (identifier) @local.definition.var) left: (identifier) @local.definition.var)

View file

@ -1,12 +1,10 @@
; Preproc ; Preproc
[ [
(unique_id) (unique_id)
(top_level_annotation_body) (top_level_annotation_body)
] @keyword.directive ] @keyword.directive
; Includes ; Includes
[ [
"import" "import"
"$import" "$import"
@ -17,7 +15,6 @@
(import_path) @string.special.path (import_path) @string.special.path
; Keywords ; Keywords
[ [
"annotation" "annotation"
"enum" "enum"
@ -30,10 +27,7 @@
] @keyword ] @keyword
; Builtins ; Builtins
"const" @type.qualifier
[
"const"
] @type.qualifier
[ [
(primitive_type) (primitive_type)
@ -41,30 +35,24 @@
] @type.builtin ] @type.builtin
; Typedefs ; Typedefs
(type_definition) @type.definition (type_definition) @type.definition
; Labels (@number, @number!) ; Labels (@number, @number!)
(field_version) @label (field_version) @label
; Methods ; Methods
[ [
(annotation_definition_identifier) (annotation_definition_identifier)
(method_identifier) (method_identifier)
] @function.method ] @function.method
; Fields ; Fields
(field_identifier) @variable.member (field_identifier) @variable.member
; Properties ; Properties
(property) @property (property) @property
; Parameters ; Parameters
[ [
(param_identifier) (param_identifier)
(return_identifier) (return_identifier)
@ -73,7 +61,6 @@
(annotation_target) @variable.parameter.builtin (annotation_target) @variable.parameter.builtin
; Constants ; Constants
[ [
(const_identifier) (const_identifier)
(local_const) (local_const)
@ -83,7 +70,6 @@
(void) @constant.builtin (void) @constant.builtin
; Types ; Types
[ [
(enum_identifier) (enum_identifier)
(extend_type) (extend_type)
@ -91,18 +77,15 @@
] @type ] @type
; Attributes ; Attributes
[ [
(annotation_identifier) (annotation_identifier)
(attribute) (attribute)
] @attribute ] @attribute
; Operators ; Operators
"=" @operator "=" @operator
; Literals ; Literals
[ [
(string) (string)
(concatenated_string) (concatenated_string)
@ -125,18 +108,26 @@
(data_hex) @string.special.symbol (data_hex) @string.special.symbol
; Punctuation ; Punctuation
[ [
"*" "*"
"$" "$"
":" ":"
] @punctuation.special ] @punctuation.special
["{" "}"] @punctuation.bracket [
"{"
"}"
] @punctuation.bracket
["(" ")"] @punctuation.bracket [
"("
")"
] @punctuation.bracket
["[" "]"] @punctuation.bracket [
"["
"]"
] @punctuation.bracket
[ [
"." "."
@ -146,5 +137,4 @@
] @punctuation.delimiter ] @punctuation.delimiter
; Comments ; Comments
(comment) @comment @spell (comment) @comment @spell

View file

@ -13,14 +13,17 @@
(field) (field)
] @indent.begin ] @indent.begin
((struct_shorthand (property)) @indent.align ((struct_shorthand
(property)) @indent.align
(#set! indent.open_delimiter "(") (#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")) (#set! indent.close_delimiter ")"))
((method (field_version)) @indent.align ((method
(field_version)) @indent.align
(#set! indent.open_delimiter field_version)) (#set! indent.open_delimiter field_version))
((const_list (const_value)) @indent.align ((const_list
(const_value)) @indent.align
(#set! indent.open_delimiter "[") (#set! indent.open_delimiter "[")
(#set! indent.close_delimiter "]")) (#set! indent.close_delimiter "]"))
@ -31,7 +34,6 @@
")" ")"
] @indent.end @indent.branch ] @indent.end @indent.branch
[ [
(ERROR) (ERROR)
(comment) (comment)

View file

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

View file

@ -18,17 +18,21 @@
(extend_type) (extend_type)
(field_type) (field_type)
] @local.reference ] @local.reference
(custom_type (type_identifier) @local.reference)
(custom_type
(type_identifier) @local.reference)
(custom_type (custom_type
(generics (generics
(generic_parameters (generic_parameters
(generic_identifier) @local.reference))) (generic_identifier) @local.reference)))
(annotation_definition_identifier) @local.definition (annotation_definition_identifier) @local.definition
(const_identifier) @local.definition.constant (const_identifier) @local.definition.constant
(enum (enum_identifier) @local.definition.enum) (enum
(enum_identifier) @local.definition.enum)
[ [
(enum_member) (enum_member)
@ -44,16 +48,19 @@
(return_identifier) (return_identifier)
] @local.definition.parameter ] @local.definition.parameter
(group (type_identifier) @local.definition.type) (group
(type_identifier) @local.definition.type)
(struct (type_identifier) @local.definition.type) (struct
(type_identifier) @local.definition.type)
(union (type_identifier) @local.definition.type) (union
(type_identifier) @local.definition.type)
(interface (type_identifier) @local.definition.type) (interface
(type_identifier) @local.definition.type)
; Generics Related (don't know how to combine these) ; Generics Related (don't know how to combine these)
(struct (struct
(generics (generics
(generic_parameters (generic_parameters

View file

@ -1,5 +1,5 @@
[ [
(intent_def) (intent_def)
(slot_def) (slot_def)
(alias_def) (alias_def)
] @fold ] @fold

View file

@ -1,24 +1,32 @@
;; Punctuation ; Punctuation
[ [
"%[" "%["
"@[" "@["
"~[" "~["
"*[" "*["
"]" "]"
"(" "("
")" ")"
] @punctuation.bracket ] @punctuation.bracket
[":" ","] @punctuation.delimiter [
":"
","
] @punctuation.delimiter
(["\"" "'"] @punctuation.special ([
(#set! conceal "")) "\""
"'"
] @punctuation.special
(#set! conceal ""))
["%" "?" "#"] @character.special [
"%"
;; Entities "?"
"#"
] @character.special
; Entities
(intent) @module (intent) @module
(slot) @type (slot) @type
@ -35,16 +43,13 @@
(escape) @string.escape (escape) @string.escape
;; Import ; Import
"import" @keyword.import "import" @keyword.import
(file) @string.special.path (file) @string.special.path
;; Text ; Text
(word) @spell (word) @spell
;; Comment ; Comment
(comment) @comment @spell (comment) @comment @spell

View file

@ -1,7 +1,8 @@
[ [
(intent_def) (intent_def)
(slot_def) (slot_def)
(alias_def) (alias_def)
] @indent.begin ] @indent.begin
(ERROR "]") @indent.begin (ERROR
"]") @indent.begin

View file

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

View file

@ -1,10 +1,16 @@
;; Definitions ; Definitions
(intent_def
(intent) @local.definition)
(intent_def (intent) @local.definition) (slot_def
(slot_def (slot) @local.definition) (slot) @local.definition)
(alias_def (alias) @local.definition)
;; References (alias_def
(alias) @local.definition)
(slot_ref (slot) @local.reference) ; References
(alias_ref (alias) @local.reference) (slot_ref
(slot) @local.reference)
(alias_ref
(alias) @local.reference)

View file

@ -1 +1,2 @@
(source (list_lit) @fold) (source
(list_lit) @fold)

View file

@ -1,69 +1,87 @@
;; >> Explanation ; >> Explanation
;; Parsers for lisps are a bit weird in that they just return the raw forms. ; Parsers for lisps are a bit weird in that they just return the raw forms.
;; This means we have to do a bit of extra work in the queries to get things ; This means we have to do a bit of extra work in the queries to get things
;; highlighted as they should be. ; highlighted as they should be.
;; ;
;; For the most part this means that some things have to be assigned multiple ; For the most part this means that some things have to be assigned multiple
;; groups. ; groups.
;; By doing this we can add a basic capture and then later refine it with more ; By doing this we can add a basic capture and then later refine it with more
;; specialized captures. ; specialized captures.
;; This can mean that sometimes things are highlighted weirdly because they ; This can mean that sometimes things are highlighted weirdly because they
;; have multiple highlight groups applied to them. ; have multiple highlight groups applied to them.
; >> Literals
((dis_expr) @comment
(#set! "priority" 105)
; Higher priority to mark the whole sexpr as a comment
)
;; >> Literals
(
(dis_expr) @comment
(#set! "priority" 105) ; Higher priority to mark the whole sexpr as a comment
)
(kwd_lit) @string.special.symbol (kwd_lit) @string.special.symbol
(str_lit) @string (str_lit) @string
(num_lit) @number (num_lit) @number
(char_lit) @character (char_lit) @character
(bool_lit) @boolean (bool_lit) @boolean
(nil_lit) @constant.builtin (nil_lit) @constant.builtin
(comment) @comment @spell (comment) @comment @spell
(regex_lit) @string.regexp (regex_lit) @string.regexp
["'" "`"] @string.escape [
"'"
"`"
] @string.escape
["~" "~@" "#"] @punctuation.special [
"~"
"~@"
"#"
] @punctuation.special
["{" "}" "[" "]" "(" ")"] @punctuation.bracket [
"{"
"}"
"["
;; >> Symbols "]"
"("
")"
] @punctuation.bracket
; >> Symbols
; General symbol highlighting ; General symbol highlighting
(sym_lit) @variable (sym_lit) @variable
; General function calls ; General function calls
(list_lit (list_lit
. .
(sym_lit) @function.call) (sym_lit) @function.call)
(anon_fn_lit (anon_fn_lit
. .
(sym_lit) @function.call) (sym_lit) @function.call)
; Quoted symbols ; Quoted symbols
(quoting_lit (quoting_lit
(sym_lit) @string.special.symbol) (sym_lit) @string.special.symbol)
(syn_quoting_lit (syn_quoting_lit
(sym_lit) @string.special.symbol) (sym_lit) @string.special.symbol)
; Used in destructure pattern ; Used in destructure pattern
((sym_lit) @variable.parameter ((sym_lit) @variable.parameter
(#lua-match? @variable.parameter "^[&]")) (#lua-match? @variable.parameter "^[&]"))
; Inline function variables ; Inline function variables
((sym_lit) @variable.builtin ((sym_lit) @variable.builtin
(#lua-match? @variable.builtin "^%%")) (#lua-match? @variable.builtin "^%%"))
; Constructor ; Constructor
((sym_lit) @constructor ((sym_lit) @constructor
(#lua-match? @constructor "^-%>[^>].*")) (#lua-match? @constructor "^-%>[^>].*"))
; Builtin dynamic variables ; Builtin dynamic variables
((sym_lit) @variable.builtin ((sym_lit) @variable.builtin
@ -84,94 +102,91 @@
; Builtin repl variables ; Builtin repl variables
((sym_lit) @variable.builtin ((sym_lit) @variable.builtin
(#any-of? @variable.builtin (#any-of? @variable.builtin "*1" "*2" "*3" "*e"))
"*1" "*2" "*3" "*e"))
; Gensym ; Gensym
;; Might not be needed ; Might not be needed
((sym_lit) @variable ((sym_lit) @variable
(#lua-match? @variable "^.*#$")) (#lua-match? @variable "^.*#$"))
; Types ; Types
;; TODO: improve? ; TODO: improve?
((sym_lit) @type ((sym_lit) @type
(#lua-match? @type "^[%u][^/]*$")) (#lua-match? @type "^[%u][^/]*$"))
;; Symbols with `.` but not `/`
; Symbols with `.` but not `/`
((sym_lit) @type ((sym_lit) @type
(#lua-match? @type "^[^/]+[.][^/]*$")) (#lua-match? @type "^[^/]+[.][^/]*$"))
; Interop ; Interop
; (.instanceMember instance args*) ; (.instanceMember instance args*)
; (.instanceMember Classname args*) ; (.instanceMember Classname args*)
((sym_lit) @function.method ((sym_lit) @function.method
(#lua-match? @function.method "^%.[^-]")) (#lua-match? @function.method "^%.[^-]"))
; (.-instanceField instance) ; (.-instanceField instance)
((sym_lit) @variable.member ((sym_lit) @variable.member
(#lua-match? @variable.member "^%.%-.*")) (#lua-match? @variable.member "^%.%-.*"))
; Classname/staticField ; Classname/staticField
((sym_lit) @variable.member ((sym_lit) @variable.member
(#lua-match? @variable.member "^[%u].*/.+")) (#lua-match? @variable.member "^[%u].*/.+"))
; (Classname/staticMethod args*) ; (Classname/staticMethod args*)
(list_lit (list_lit
. .
(sym_lit) @function.method (sym_lit) @function.method
(#lua-match? @function.method "^[%u].*/.+")) (#lua-match? @function.method "^[%u].*/.+"))
;; TODO: Special casing for the `.` macro
; TODO: Special casing for the `.` macro
; Operators ; Operators
((sym_lit) @operator ((sym_lit) @operator
(#any-of? @operator (#any-of? @operator "*" "*'" "+" "+'" "-" "-'" "/" "<" "<=" ">" ">=" "=" "=="))
"*" "*'" "+" "+'" "-" "-'" "/"
"<" "<=" ">" ">=" "=" "=="))
((sym_lit) @keyword.operator ((sym_lit) @keyword.operator
(#any-of? @keyword.operator (#any-of? @keyword.operator "not" "not=" "and" "or"))
"not" "not=" "and" "or"))
; Definition functions ; Definition functions
((sym_lit) @keyword ((sym_lit) @keyword
(#any-of? @keyword (#any-of? @keyword "def" "defonce" "defrecord" "defmacro" "definline" "definterface" "defmulti" "defmethod" "defstruct" "defprotocol" "deftype"))
"def" "defonce" "defrecord" "defmacro" "definline" "definterface"
"defmulti" "defmethod" "defstruct" "defprotocol"
"deftype"))
((sym_lit) @keyword ((sym_lit) @keyword
(#eq? @keyword "declare")) (#eq? @keyword "declare"))
((sym_name) @keyword.coroutine ((sym_name) @keyword.coroutine
(#any-of? @keyword.coroutine (#any-of? @keyword.coroutine "alts!" "alts!!" "await" "await-for" "await1" "chan" "close!" "future" "go" "sync" "thread" "timeout" "<!" "<!!" ">!" ">!!"))
"alts!" "alts!!" "await" "await-for" "await1" "chan" "close!" "future" "go" "sync" "thread" "timeout" "<!" "<!!" ">!" ">!!"))
((sym_lit) @keyword.function ((sym_lit) @keyword.function
(#any-of? @keyword.function "defn" "defn-" "fn" "fn*")) (#any-of? @keyword.function "defn" "defn-" "fn" "fn*"))
; Comment ; Comment
((sym_lit) @comment ((sym_lit) @comment
(#any-of? @comment "comment")) (#any-of? @comment "comment"))
; Conditionals ; Conditionals
((sym_lit) @keyword.conditional ((sym_lit) @keyword.conditional
(#any-of? @keyword.conditional (#any-of? @keyword.conditional "case" "cond" "cond->" "cond->>" "condp"))
"case" "cond" "cond->" "cond->>" "condp"))
((sym_lit) @keyword.conditional ((sym_lit) @keyword.conditional
(#any-of? @keyword.conditional (#any-of? @keyword.conditional "if" "if-let" "if-not" "if-some"))
"if" "if-let" "if-not" "if-some"))
((sym_lit) @keyword.conditional ((sym_lit) @keyword.conditional
(#any-of? @keyword.conditional (#any-of? @keyword.conditional "when" "when-first" "when-let" "when-not" "when-some"))
"when" "when-first" "when-let" "when-not" "when-some"))
; Repeats ; Repeats
((sym_lit) @keyword.repeat ((sym_lit) @keyword.repeat
(#any-of? @keyword.repeat (#any-of? @keyword.repeat "doseq" "dotimes" "for" "loop" "recur" "while"))
"doseq" "dotimes" "for" "loop" "recur" "while"))
; Exception ; Exception
((sym_lit) @keyword.exception ((sym_lit) @keyword.exception
(#any-of? @keyword.exception (#any-of? @keyword.exception "throw" "try" "catch" "finally"))
"throw" "try" "catch" "finally"))
; Includes ; Includes
((sym_lit) @keyword.import ((sym_lit) @keyword.import
(#any-of? @keyword.import "ns" "import" "require" "use")) (#any-of? @keyword.import "ns" "import" "require" "use"))
; Builtin macros ; Builtin macros
;; TODO: Do all these items belong here? ; TODO: Do all these items belong here?
((sym_lit) @function.macro ((sym_lit) @function.macro
; format-ignore ; format-ignore
(#any-of? @function.macro (#any-of? @function.macro
@ -191,7 +206,7 @@
; (keep (fn [[s v]] (when-not (:macro (meta v)) s))) ; (keep (fn [[s v]] (when-not (:macro (meta v)) s)))
; sort ; sort
; clojure.pprint/pprint)) ; clojure.pprint/pprint))
;; ...and then lots of manual filtering... ; ...and then lots of manual filtering...
((sym_lit) @function.builtin ((sym_lit) @function.builtin
; format-ignore ; format-ignore
(#any-of? @function.builtin (#any-of? @function.builtin
@ -316,48 +331,43 @@
"seq-to-map-for-destructuring" "update-keys" "update-vals" "seq-to-map-for-destructuring" "update-keys" "update-vals"
;; 1.12 ;; 1.12
"partitionv" "partitionv-all" "splitv-at")) "partitionv" "partitionv-all" "splitv-at"))
; >> Context based highlighting
; def-likes
; Correctly highlight docstrings
;; >> Context based highlighting
;; def-likes
;; Correctly highlight docstrings
;(list_lit ;(list_lit
;. ;.
;(sym_lit) @_keyword ; Don't really want to highlight twice ;(sym_lit) @_keyword ; Don't really want to highlight twice
;(#any-of? @_keyword ;(#any-of? @_keyword
;"def" "defonce" "defrecord" "defmacro" "definline" ;"def" "defonce" "defrecord" "defmacro" "definline"
;"defmulti" "defmethod" "defstruct" "defprotocol" ;"defmulti" "defmethod" "defstruct" "defprotocol"
;"deftype") ;"deftype")
;. ;.
;(sym_lit) ;(sym_lit)
;. ;.
;;; TODO: Add @comment highlight ; TODO: Add @comment highlight
;(str_lit)? ;(str_lit)?
;. ;.
;(_)) ;(_))
; Function definitions ; Function definitions
(list_lit (list_lit
. .
(sym_lit) @_keyword.function (sym_lit) @_keyword.function
(#any-of? @_keyword.function "fn" "fn*" "defn" "defn-") (#any-of? @_keyword.function "fn" "fn*" "defn" "defn-")
. .
(sym_lit)? @function (sym_lit)? @function
. .
;; TODO: Add @comment highlight ; TODO: Add @comment highlight
(str_lit)?) (str_lit)?)
;; TODO: Fix parameter highlighting
;; I think there's a bug here in nvim-treesitter ; TODO: Fix parameter highlighting
;; TODO: Reproduce bug and file ticket ; I think there's a bug here in nvim-treesitter
;. ; TODO: Reproduce bug and file ticket
;[(vec_lit ;.
; (sym_lit)* @variable.parameter) ;[(vec_lit
; (list_lit ; (sym_lit)* @variable.parameter)
; (vec_lit ; (list_lit
; (sym_lit)* @variable.parameter))]) ; (vec_lit
; (sym_lit)* @variable.parameter))])
;[((list_lit ;[((list_lit
; (vec_lit ; (vec_lit
; (sym_lit) @variable.parameter) ; (sym_lit) @variable.parameter)
@ -366,19 +376,17 @@
; ((vec_lit ; ((vec_lit
; (sym_lit) @variable.parameter) ; (sym_lit) @variable.parameter)
; (_))) ; (_)))
; Meta punctuation ; Meta punctuation
;; NOTE: When the above `Function definitions` query captures the ; NOTE: When the above `Function definitions` query captures the
;; the @function it also captures the child meta_lit ; the @function it also captures the child meta_lit
;; We capture the meta_lit symbol (^) after so that the later ; We capture the meta_lit symbol (^) after so that the later
;; highlighting overrides the former ; highlighting overrides the former
"^" @punctuation.special "^" @punctuation.special
;; namespaces ; namespaces
(list_lit (list_lit
. .
(sym_lit) @_include (sym_lit) @_include
(#eq? @_include "ns") (#eq? @_include "ns")
. .
(sym_lit) @module) (sym_lit) @module)

View file

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

View file

@ -1,8 +1,8 @@
[ [
(if_condition) (if_condition)
(foreach_loop) (foreach_loop)
(while_loop) (while_loop)
(function_def) (function_def)
(macro_def) (macro_def)
(block_def) (block_def)
] @fold ] @fold

View file

@ -1,96 +1,107 @@
(normal_command (normal_command
(identifier) (identifier)
(argument_list (argument_list
(argument (unquoted_argument)) @constant (argument
) (unquoted_argument)) @constant)
(#lua-match? @constant "^[%u@][%u%d_]+$") (#lua-match? @constant "^[%u@][%u%d_]+$"))
)
[ [
(quoted_argument) (quoted_argument)
(bracket_argument) (bracket_argument)
] @string ] @string
(variable_ref) @none (variable_ref) @none
(variable) @variable (variable) @variable
[ [
(bracket_comment) (bracket_comment)
(line_comment) (line_comment)
] @comment @spell ] @comment @spell
(normal_command (identifier) @function) (normal_command
(identifier) @function)
["ENV" "CACHE"] @keyword.storage
["$" "{" "}" "<" ">"] @punctuation.special
["(" ")"] @punctuation.bracket
[ [
(function) "ENV"
(endfunction) "CACHE"
(macro) ] @keyword.storage
(endmacro)
[
"$"
"{"
"}"
"<"
">"
] @punctuation.special
[
"("
")"
] @punctuation.bracket
[
(function)
(endfunction)
(macro)
(endmacro)
] @keyword.function ] @keyword.function
[ [
(if) (if)
(elseif) (elseif)
(else) (else)
(endif) (endif)
] @keyword.conditional ] @keyword.conditional
[ [
(foreach) (foreach)
(endforeach) (endforeach)
(while) (while)
(endwhile) (endwhile)
] @keyword.repeat ] @keyword.repeat
(normal_command (normal_command
(identifier) @keyword.repeat (identifier) @keyword.repeat
(#match? @keyword.repeat "\\c^(continue|break)$") (#match? @keyword.repeat "\\c^(continue|break)$"))
)
(normal_command (normal_command
(identifier) @keyword.return (identifier) @keyword.return
(#match? @keyword.return "\\c^return$") (#match? @keyword.return "\\c^return$"))
)
(function_command (function_command
(function) (function)
(argument_list (argument_list
. (argument) @function .
(argument)* @variable.parameter (argument) @function
) (argument)* @variable.parameter))
)
(macro_command (macro_command
(macro) (macro)
(argument_list (argument_list
. (argument) @function.macro .
(argument)* @variable.parameter (argument) @function.macro
) (argument)* @variable.parameter))
)
(block_def (block_def
(block_command (block_command
(block) @function.builtin (block) @function.builtin
(argument_list (argument_list
(argument (unquoted_argument) @constant) (argument
) (unquoted_argument) @constant))
(#any-of? @constant "SCOPE_FOR" "POLICIES" "VARIABLES" "PROPAGATE") (#any-of? @constant "SCOPE_FOR" "POLICIES" "VARIABLES" "PROPAGATE"))
) (endblock_command
(endblock_command (endblock) @function.builtin) (endblock) @function.builtin))
)
; ;
((argument) @boolean ((argument) @boolean
(#match? @boolean "\\c^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$") (#match? @boolean "\\c^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$"))
)
; ;
(if_command (if_command
(if) (if)
(argument_list (argument_list
(argument) @keyword.operator (argument) @keyword.operator)
)
; format-ignore ; format-ignore
(#any-of? @keyword.operator (#any-of? @keyword.operator
"NOT" "AND" "OR" "NOT" "AND" "OR"
@ -100,13 +111,12 @@
"LESS" "GREATER" "EQUAL" "LESS_EQUAL" "GREATER_EQUAL" "LESS" "GREATER" "EQUAL" "LESS_EQUAL" "GREATER_EQUAL"
"STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL" "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL"
"VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL" "VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL"
) ))
)
(elseif_command (elseif_command
(elseif) (elseif)
(argument_list (argument_list
(argument) @keyword.operator (argument) @keyword.operator)
)
; format-ignore ; format-ignore
(#any-of? @keyword.operator (#any-of? @keyword.operator
"NOT" "AND" "OR" "NOT" "AND" "OR"
@ -116,106 +126,105 @@
"LESS" "GREATER" "EQUAL" "LESS_EQUAL" "GREATER_EQUAL" "LESS" "GREATER" "EQUAL" "LESS_EQUAL" "GREATER_EQUAL"
"STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL" "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL"
"VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL" "VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL"
) ))
)
(normal_command (normal_command
(identifier) @function.builtin (identifier) @function.builtin
(#match? @function.builtin "\\c^(cmake_host_system_information|cmake_language|cmake_minimum_required|cmake_parse_arguments|cmake_path|cmake_policy|configure_file|execute_process|file|find_file|find_library|find_package|find_path|find_program|foreach|get_cmake_property|get_directory_property|get_filename_component|get_property|include|include_guard|list|macro|mark_as_advanced|math|message|option|separate_arguments|set|set_directory_properties|set_property|site_name|string|unset|variable_watch|add_compile_definitions|add_compile_options|add_custom_command|add_custom_target|add_definitions|add_dependencies|add_executable|add_library|add_link_options|add_subdirectory|add_test|aux_source_directory|build_command|create_test_sourcelist|define_property|enable_language|enable_testing|export|fltk_wrap_ui|get_source_file_property|get_target_property|get_test_property|include_directories|include_external_msproject|include_regular_expression|install|link_directories|link_libraries|load_cache|project|remove_definitions|set_source_files_properties|set_target_properties|set_tests_properties|source_group|target_compile_definitions|target_compile_features|target_compile_options|target_include_directories|target_link_directories|target_link_libraries|target_link_options|target_precompile_headers|target_sources|try_compile|try_run|ctest_build|ctest_configure|ctest_coverage|ctest_empty_binary_directory|ctest_memcheck|ctest_read_custom_files|ctest_run_script|ctest_sleep|ctest_start|ctest_submit|ctest_test|ctest_update|ctest_upload)$") (#match? @function.builtin "\\c^(cmake_host_system_information|cmake_language|cmake_minimum_required|cmake_parse_arguments|cmake_path|cmake_policy|configure_file|execute_process|file|find_file|find_library|find_package|find_path|find_program|foreach|get_cmake_property|get_directory_property|get_filename_component|get_property|include|include_guard|list|macro|mark_as_advanced|math|message|option|separate_arguments|set|set_directory_properties|set_property|site_name|string|unset|variable_watch|add_compile_definitions|add_compile_options|add_custom_command|add_custom_target|add_definitions|add_dependencies|add_executable|add_library|add_link_options|add_subdirectory|add_test|aux_source_directory|build_command|create_test_sourcelist|define_property|enable_language|enable_testing|export|fltk_wrap_ui|get_source_file_property|get_target_property|get_test_property|include_directories|include_external_msproject|include_regular_expression|install|link_directories|link_libraries|load_cache|project|remove_definitions|set_source_files_properties|set_target_properties|set_tests_properties|source_group|target_compile_definitions|target_compile_features|target_compile_options|target_include_directories|target_link_directories|target_link_libraries|target_link_options|target_precompile_headers|target_sources|try_compile|try_run|ctest_build|ctest_configure|ctest_coverage|ctest_empty_binary_directory|ctest_memcheck|ctest_read_custom_files|ctest_run_script|ctest_sleep|ctest_start|ctest_submit|ctest_test|ctest_update|ctest_upload)$"))
)
(normal_command (normal_command
(identifier) @_function (identifier) @_function
(argument_list (argument_list
. (argument) @variable
)
(#match? @_function "\\c^set$")
)
(normal_command
(identifier) @_function
(#match? @_function "\\c^set$")
(argument_list
. (argument)
(
(argument) @_cache @keyword.storage
. .
(argument) @_type @type (argument) @variable)
(#any-of? @_cache "CACHE") (#match? @_function "\\c^set$"))
(#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL")
) (normal_command
) (identifier) @_function
) (#match? @_function "\\c^set$")
(argument_list
.
(argument)
((argument) @_cache @keyword.storage
.
(argument) @_type @type
(#any-of? @_cache "CACHE")
(#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL"))))
(normal_command (normal_command
(identifier) @_function (identifier) @_function
(#match? @_function "\\c^unset$") (#match? @_function "\\c^unset$")
(argument_list (argument_list
. (argument) .
(argument)
(argument) @keyword.storage (argument) @keyword.storage
(#any-of? @keyword.storage "CACHE" "PARENT_SCOPE") (#any-of? @keyword.storage "CACHE" "PARENT_SCOPE")))
)
)
(normal_command (normal_command
(identifier) @_function (identifier) @_function
(#match? @_function "\\c^list$") (#match? @_function "\\c^list$")
(argument_list (argument_list
. (argument) @constant .
(argument) @constant
(#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND") (#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND")
. (argument) @variable .
(argument) @variable . (argument) @variable
) (argument) @variable .))
)
(normal_command (normal_command
(identifier) @_function (identifier) @_function
(#match? @_function "\\c^list$") (#match? @_function "\\c^list$")
(argument_list (argument_list
. (argument) @constant .
. (argument) @variable (argument) @constant
(#any-of? @constant "APPEND" "FILTER" "INSERT" .
"POP_BACK" "POP_FRONT" "PREPEND" (argument) @variable
"REMOVE_ITEM" "REMOVE_AT" "REMOVE_DUPLICATES" (#any-of? @constant "APPEND" "FILTER" "INSERT" "POP_BACK" "POP_FRONT" "PREPEND" "REMOVE_ITEM" "REMOVE_AT" "REMOVE_DUPLICATES" "REVERSE" "SORT")))
"REVERSE" "SORT")
)
)
(normal_command (normal_command
(identifier) @_function (identifier) @_function
(#match? @_function "\\c^list$") (#match? @_function "\\c^list$")
(argument_list (argument_list
. (argument) @_transform @constant .
. (argument) @variable (argument) @_transform @constant
. (argument) @_action @constant .
(argument) @variable
.
(argument) @_action @constant
(#eq? @_transform "TRANSFORM")
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")))
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
(argument_list
.
(argument) @_transform @constant
.
(argument) @variable
.
(argument) @_action @constant
.
(argument)? @_selector @constant
(#eq? @_transform "TRANSFORM") (#eq? @_transform "TRANSFORM")
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE") (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
) (#any-of? @_selector "AT" "FOR" "REGEX")))
)
(normal_command (normal_command
(identifier) @_function (identifier) @_function
(#match? @_function "\\c^list$") (#match? @_function "\\c^list$")
(argument_list (argument_list
. (argument) @_transform @constant .
. (argument) @variable (argument) @_transform @constant
. (argument) @_action @constant (argument) @constant
. (argument)? @_selector @constant .
(#eq? @_transform "TRANSFORM")
(#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE")
(#any-of? @_selector "AT" "FOR" "REGEX")
)
)
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
(argument_list
. (argument) @_transform @constant
(argument) @constant .
(argument) @variable (argument) @variable
(#eq? @_transform "TRANSFORM") (#eq? @_transform "TRANSFORM")
(#eq? @constant "OUTPUT_VARIABLE") (#eq? @constant "OUTPUT_VARIABLE")))
)
)
(escape_sequence) @string.escape (escape_sequence) @string.escape
((source_file . (line_comment) @keyword.directive) ((source_file
.
(line_comment) @keyword.directive)
(#lua-match? @keyword.directive "^#!/")) (#lua-match? @keyword.directive "^#!/"))

View file

@ -9,17 +9,18 @@
] @indent.begin ] @indent.begin
[ [
(elseif_command) (elseif_command)
(else_command) (else_command)
(endif_command) (endif_command)
(endforeach_command) (endforeach_command)
(endwhile_command) (endwhile_command)
(endfunction_command) (endfunction_command)
(endmacro_command) (endmacro_command)
(endblock_command) (endblock_command)
] @indent.branch ] @indent.branch
(")" @indent.branch) (")" @indent.branch)
(")" @indent.end) (")" @indent.end)
(argument_list) @indent.auto (argument_list) @indent.auto

View file

@ -11,33 +11,39 @@
((tag ((tag
(name) @comment.note @nospell (name) @comment.note @nospell
("(" @punctuation.bracket (user) @constant ")" @punctuation.bracket)? ("(" @punctuation.bracket
(user) @constant
")" @punctuation.bracket)?
":" @punctuation.delimiter) ":" @punctuation.delimiter)
(#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST")) (#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST"))
("text" @comment.note @nospell ("text" @comment.note @nospell
(#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST")) (#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST"))
((tag ((tag
(name) @comment.warning @nospell (name) @comment.warning @nospell
("(" @punctuation.bracket (user) @constant ")" @punctuation.bracket)? ("(" @punctuation.bracket
(user) @constant
")" @punctuation.bracket)?
":" @punctuation.delimiter) ":" @punctuation.delimiter)
(#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX")) (#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX"))
("text" @comment.warning @nospell ("text" @comment.warning @nospell
(#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX")) (#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX"))
((tag ((tag
(name) @comment.error @nospell (name) @comment.error @nospell
("(" @punctuation.bracket (user) @constant ")" @punctuation.bracket)? ("(" @punctuation.bracket
(user) @constant
")" @punctuation.bracket)?
":" @punctuation.delimiter) ":" @punctuation.delimiter)
(#any-of? @comment.error "FIXME" "BUG" "ERROR")) (#any-of? @comment.error "FIXME" "BUG" "ERROR"))
("text" @comment.error @nospell ("text" @comment.error @nospell
(#any-of? @comment.error "FIXME" "BUG" "ERROR")) (#any-of? @comment.error "FIXME" "BUG" "ERROR"))
; Issue number (#123) ; Issue number (#123)
("text" @number ("text" @number
(#lua-match? @number "^#[0-9]+$")) (#lua-match? @number "^#[0-9]+$"))
((uri) @string.special.url @nospell) ((uri) @string.special.url @nospell)

View file

@ -1 +1,2 @@
(source (list_lit) @fold) (source
(list_lit) @fold)

File diff suppressed because one or more lines are too long

View file

@ -1,72 +1,113 @@
(defun_header
function_name: (sym_lit) @local.definition.function
(#set! definition.function.scope "parent"))
(defun_header (defun_header
function_name: (sym_lit) @local.definition.function (#set! definition.function.scope "parent")) lambda_list:
(defun_header (list_lit
lambda_list: (list_lit (sym_lit) @local.definition.parameter)) (sym_lit) @local.definition.parameter))
(defun_header (defun_header
keyword: (defun_keyword "defmethod") keyword:
lambda_list: (list_lit (list_lit . (sym_lit) . (sym_lit) @local.definition.type))) (defun_keyword
"defmethod")
lambda_list:
(list_lit
(list_lit
.
(sym_lit)
.
(sym_lit) @local.definition.type)))
(defun_header (defun_header
lambda_list: (list_lit (list_lit . (sym_lit) @local.definition.parameter . (_)))) lambda_list:
(list_lit
(list_lit
.
(sym_lit) @local.definition.parameter
.
(_))))
(sym_lit) @local.reference (sym_lit) @local.reference
(defun) @local.scope (defun) @local.scope
((list_lit . (sym_lit) @_defvar . (sym_lit) @local.definition.var) ((list_lit
(#match? @_defvar "^(cl:)?(defvar|defparameter)$")) .
(sym_lit) @_defvar
.
(sym_lit) @local.definition.var)
(#match? @_defvar "^(cl:)?(defvar|defparameter)$"))
(list_lit (list_lit
. .
(sym_lit) @_deftest (sym_lit) @_deftest
. .
(sym_lit) @local.definition.function (sym_lit) @local.definition.function
(#eq? @_deftest "deftest")) @local.scope (#eq? @_deftest "deftest")) @local.scope
(list_lit (list_lit
. .
(sym_lit) @_deftest (sym_lit) @_deftest
. .
(sym_lit) @local.definition.function (sym_lit) @local.definition.function
(#eq? @_deftest "deftest")) @local.scope (#eq? @_deftest "deftest")) @local.scope
(for_clause
.
(sym_lit) @local.definition.var)
(with_clause
.
(sym_lit) @local.definition.var)
(for_clause . (sym_lit) @local.definition.var)
(with_clause . (sym_lit) @local.definition.var)
(loop_macro) @local.scope (loop_macro) @local.scope
(list_lit (list_lit
. .
(sym_lit) @_let (#match? @_let "(cl:|cffi:)?(with-accessors|with-foreign-objects|let[*]?)") (sym_lit) @_let
. (#match? @_let "(cl:|cffi:)?(with-accessors|with-foreign-objects|let[*]?)")
(list_lit (list_lit . (sym_lit) @local.definition.var))) @local.scope .
(list_lit
(list_lit
.
(sym_lit) @local.definition.var))) @local.scope
(list_lit (list_lit
. .
(sym_lit) @_let (#match? @_let "(cl:|alexandria:)?(with-gensyms|dotimes|with-foreign-object)") (sym_lit) @_let
. (#match? @_let "(cl:|alexandria:)?(with-gensyms|dotimes|with-foreign-object)")
(list_lit . (sym_lit) @local.definition.var)) @local.scope .
(list_lit
.
(sym_lit) @local.definition.var)) @local.scope
(list_lit (list_lit
. .
(kwd_lit) @_import_from (#eq? @_import_from ":import-from") (kwd_lit) @_import_from
. (#eq? @_import_from ":import-from")
(_) .
(kwd_lit (kwd_symbol) @local.definition.import)) (_)
(kwd_lit
(kwd_symbol) @local.definition.import))
(list_lit (list_lit
. .
(kwd_lit) @_import_from (#eq? @_import_from ":import-from") (kwd_lit) @_import_from
. (#eq? @_import_from ":import-from")
(_) .
(sym_lit) @local.definition.import) (_)
(sym_lit) @local.definition.import)
(list_lit (list_lit
. .
(kwd_lit) @_use (#eq? @_use ":use") (kwd_lit) @_use
(kwd_lit (kwd_symbol) @local.definition.import)) (#eq? @_use ":use")
(kwd_lit
(kwd_symbol) @local.definition.import))
(list_lit (list_lit
. .
(kwd_lit) @_use (#eq? @_use ":use") (kwd_lit) @_use
(sym_lit) @local.definition.import) (#eq? @_use ":use")
(sym_lit) @local.definition.import)

View file

@ -3,20 +3,20 @@
(ingredient (ingredient
"@" @tag "@" @tag
(name)? @markup.heading (name)? @markup.heading
(amount (amount
(quantity)? @number (quantity)? @number
(units)? @tag.attribute)?) (units)? @tag.attribute)?)
(timer (timer
"~" @tag "~" @tag
(name)? @markup.heading (name)? @markup.heading
(amount (amount
(quantity)? @number (quantity)? @number
(units)? @tag.attribute)?) (units)? @tag.attribute)?)
(cookware (cookware
"#" @tag "#" @tag
(name)? @markup.heading (name)? @markup.heading
(amount (amount
(quantity)? @number (quantity)? @number
(units)? @tag.attribute)?) (units)? @tag.attribute)?)

View file

@ -1,5 +1,5 @@
[ [
(object) (object)
(array) (array)
(assign_block) (assign_block)
] @fold ] @fold

View file

@ -1,4 +1,5 @@
"let" @keyword "let" @keyword
"in" @keyword "in" @keyword
[ [
@ -11,10 +12,15 @@
"." @punctuation.delimiter "." @punctuation.delimiter
(input) @constant (input) @constant
(comment) @comment @spell (comment) @comment @spell
(string) @string (string) @string
(integer) @number (integer) @number
(float) @number.float (float) @number.float
(boolean) @boolean (boolean) @boolean
(null) @keyword (null) @keyword

View file

@ -1,14 +1,24 @@
[ [
(assign_block "{") (assign_block
(object) "{")
(array) (object)
(array)
] @indent.begin ] @indent.begin
(assign_block "}" @indent.branch) (assign_block
(assign_block "}" @indent.end) "}" @indent.branch)
(object "}" @indent.branch) (assign_block
(object "}" @indent.end) "}" @indent.end)
(array "]" @indent.branch) (object
(array "]" @indent.end) "}" @indent.branch)
(object
"}" @indent.end)
(array
"]" @indent.branch)
(array
"]" @indent.end)

View file

@ -1,16 +1,13 @@
; scopes ; scopes
[ [
(object) (object)
(array) (array)
] @local.scope ] @local.scope
; definitions ; definitions
(assign_block
(assign_block
(assignment (assignment
(input) (input) @local.definition.constant))
@local.definition.constant))
(value (input) @local.reference)
(value
(input) @local.reference)

View file

@ -1,6 +1,6 @@
; Literals ; Literals
(string) @string (string) @string
(escape_sequence) @string.escape (escape_sequence) @string.escape
(hex_blob (hex_blob
@ -15,7 +15,8 @@
"d" @character.special "d" @character.special
(_) @string.special) (_) @string.special)
(_ key: (_) @label) (_
key: (_) @label)
(number) @number (number) @number
@ -26,21 +27,28 @@
(null) @constant.builtin (null) @constant.builtin
; Punctuation ; Punctuation
[ [
"," ","
":" ":"
] @punctuation.delimiter ] @punctuation.delimiter
[ "{" "}" ] @punctuation.bracket [
"{"
"}"
] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket [
"["
"]"
] @punctuation.bracket
[ "<" ">" ] @punctuation.bracket [
"<"
">"
] @punctuation.bracket
(("\"" @string) (("\"" @string)
(#set! conceal "")) (#set! conceal ""))
; Comments ; Comments
(comment) @comment @spell (comment) @comment @spell

View file

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

View file

@ -1,6 +1,5 @@
[ [
(document) (document)
(meta_map) (meta_map)
(map) (map)
(array) (array)

View file

@ -1,14 +1,13 @@
; inherits: c ; inherits: c
[ [
(for_range_loop) (for_range_loop)
(class_specifier) (class_specifier)
(field_declaration (field_declaration
type: (enum_specifier) type: (enum_specifier)
default_value: (initializer_list)) default_value: (initializer_list))
(template_declaration) (template_declaration)
(namespace_definition) (namespace_definition)
(try_statement) (try_statement)
(catch_clause) (catch_clause)
(lambda_expression) (lambda_expression)
] @fold ] @fold

View file

@ -1,5 +1,4 @@
; inherits: c ; inherits: c
((identifier) @variable.member ((identifier) @variable.member
(#lua-match? @variable.member "^m_.*$")) (#lua-match? @variable.member "^m_.*$"))
@ -8,23 +7,24 @@
; function(Foo ...foo) ; function(Foo ...foo)
(variadic_parameter_declaration (variadic_parameter_declaration
declarator: (variadic_declarator declarator:
(_) @variable.parameter)) (variadic_declarator
(_) @variable.parameter))
; int foo = 0 ; int foo = 0
(optional_parameter_declaration (optional_parameter_declaration
declarator: (_) @variable.parameter) declarator: (_) @variable.parameter)
;(field_expression) @variable.parameter ;; How to highlight this? ;(field_expression) @variable.parameter ;; How to highlight this?
(((field_expression (((field_expression
(field_identifier) @function.method)) @_parent (field_identifier) @function.method)) @_parent
(#has-parent? @_parent template_method function_declarator)) (#has-parent? @_parent template_method function_declarator))
(field_declaration (field_declaration
(field_identifier) @variable.member) (field_identifier) @variable.member)
(field_initializer (field_initializer
(field_identifier) @property) (field_identifier) @property)
(function_declarator (function_declarator
declarator: (field_identifier) @function.method) declarator: (field_identifier) @function.method)
@ -38,13 +38,25 @@
(auto) @type.builtin (auto) @type.builtin
(namespace_identifier) @module (namespace_identifier) @module
((namespace_identifier) @type ((namespace_identifier) @type
(#lua-match? @type "^[%u]")) (#lua-match? @type "^[%u]"))
(case_statement (case_statement
value: (qualified_identifier (identifier) @constant)) value:
(qualified_identifier
(identifier) @constant))
(using_declaration . "using" . "namespace" . [(qualified_identifier) (identifier)] @module) (using_declaration
.
"using"
.
"namespace"
.
[
(qualified_identifier)
(identifier)
] @module)
(destructor_name (destructor_name
(identifier) @function.method) (identifier) @function.method)
@ -53,15 +65,18 @@
(function_declarator (function_declarator
(qualified_identifier (qualified_identifier
(identifier) @function)) (identifier) @function))
(function_declarator (function_declarator
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
(identifier) @function))) (identifier) @function)))
(function_declarator (function_declarator
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
(identifier) @function)))) (identifier) @function))))
((qualified_identifier ((qualified_identifier
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
@ -74,21 +89,26 @@
(identifier) @function)) (identifier) @function))
(operator_name) @function (operator_name) @function
"operator" @function "operator" @function
"static_assert" @function.builtin "static_assert" @function.builtin
(call_expression (call_expression
(qualified_identifier (qualified_identifier
(identifier) @function.call)) (identifier) @function.call))
(call_expression (call_expression
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
(identifier) @function.call))) (identifier) @function.call)))
(call_expression (call_expression
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
(identifier) @function.call)))) (identifier) @function.call))))
((qualified_identifier ((qualified_identifier
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
@ -99,21 +119,25 @@
(call_expression (call_expression
(template_function (template_function
(identifier) @function.call)) (identifier) @function.call))
(call_expression (call_expression
(qualified_identifier (qualified_identifier
(template_function (template_function
(identifier) @function.call))) (identifier) @function.call)))
(call_expression (call_expression
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
(template_function (template_function
(identifier) @function.call)))) (identifier) @function.call))))
(call_expression (call_expression
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
(template_function (template_function
(identifier) @function.call))))) (identifier) @function.call)))))
((qualified_identifier ((qualified_identifier
(qualified_identifier (qualified_identifier
(qualified_identifier (qualified_identifier
@ -126,12 +150,12 @@
(function_declarator (function_declarator
(template_method (template_method
(field_identifier) @function.method)) (field_identifier) @function.method))
(call_expression (call_expression
(field_expression (field_expression
(field_identifier) @function.method.call)) (field_identifier) @function.method.call))
; constructors ; constructors
((function_declarator ((function_declarator
(qualified_identifier (qualified_identifier
(identifier) @constructor)) (identifier) @constructor))
@ -139,93 +163,91 @@
((call_expression ((call_expression
function: (identifier) @constructor) function: (identifier) @constructor)
(#lua-match? @constructor "^%u")) (#lua-match? @constructor "^%u"))
((call_expression
function: (qualified_identifier
name: (identifier) @constructor))
(#lua-match? @constructor "^%u"))
((call_expression ((call_expression
function: (field_expression function:
field: (field_identifier) @constructor)) (qualified_identifier
(#lua-match? @constructor "^%u")) name: (identifier) @constructor))
(#lua-match? @constructor "^%u"))
;; constructing a type in an initializer list: Constructor (): **SuperType (1)** ((call_expression
function:
(field_expression
field: (field_identifier) @constructor))
(#lua-match? @constructor "^%u"))
; constructing a type in an initializer list: Constructor (): **SuperType (1)**
((field_initializer ((field_initializer
(field_identifier) @constructor (field_identifier) @constructor
(argument_list)) (argument_list))
(#lua-match? @constructor "^%u")) (#lua-match? @constructor "^%u"))
; Constants ; Constants
(this) @variable.builtin (this) @variable.builtin
(null "nullptr" @constant.builtin)
(null
"nullptr" @constant.builtin)
(true) @boolean (true) @boolean
(false) @boolean (false) @boolean
; Literals ; Literals
(raw_string_literal) @string
(raw_string_literal) @string
; Keywords ; Keywords
[ [
"try" "try"
"catch" "catch"
"noexcept" "noexcept"
"throw" "throw"
] @keyword.exception ] @keyword.exception
[ [
"class" "class"
"decltype" "decltype"
"explicit" "explicit"
"friend" "friend"
"namespace" "namespace"
"override" "override"
"template" "template"
"typename" "typename"
"using" "using"
"concept" "concept"
"requires" "requires"
"constexpr" "constexpr"
] @keyword ] @keyword
[ "co_await" @keyword.coroutine
"co_await"
] @keyword.coroutine
[ [
"co_yield" "co_yield"
"co_return" "co_return"
] @keyword.coroutine.return ] @keyword.coroutine.return
[ [
"public" "public"
"private" "private"
"protected" "protected"
"virtual" "virtual"
"final" "final"
] @type.qualifier ] @type.qualifier
[ [
"new" "new"
"delete" "delete"
"xor"
"xor" "bitand"
"bitand" "bitor"
"bitor" "compl"
"compl" "not"
"not" "xor_eq"
"xor_eq" "and_eq"
"and_eq" "or_eq"
"or_eq" "not_eq"
"not_eq" "and"
"and" "or"
"or"
] @keyword.operator ] @keyword.operator
"<=>" @operator "<=>" @operator
@ -233,9 +255,15 @@
"::" @punctuation.delimiter "::" @punctuation.delimiter
(template_argument_list (template_argument_list
["<" ">"] @punctuation.bracket) [
"<"
">"
] @punctuation.bracket)
(template_parameter_list (template_parameter_list
["<" ">"] @punctuation.bracket) [
"<"
">"
] @punctuation.bracket)
(literal_suffix) @operator (literal_suffix) @operator

View file

@ -1,9 +1,7 @@
; inherits: c ; inherits: c
(condition_clause) @indent.begin
[
(condition_clause)
] @indent.begin
((field_initializer_list) @indent.begin ((field_initializer_list) @indent.begin
(#set! indent.start_at_same_line 1)) (#set! indent.start_at_same_line 1))
(access_specifier) @indent.branch (access_specifier) @indent.branch

View file

@ -1,8 +1,5 @@
((preproc_arg) @injection.content ((preproc_arg) @injection.content
(#set! injection.language "cpp")) (#set! injection.language "cpp"))
((comment) @injection.content
(#set! injection.language "comment"))
((comment) @injection.content ((comment) @injection.content
(#lua-match? @injection.content "/[*][!<*][^a-zA-Z]") (#lua-match? @injection.content "/[*][!<*][^a-zA-Z]")

View file

@ -1,12 +1,14 @@
; inherits: c ; inherits: c
; Parameters
;; Parameters
(variadic_parameter_declaration (variadic_parameter_declaration
declarator: (variadic_declarator declarator:
(identifier) @local.definition.parameter)) (variadic_declarator
(identifier) @local.definition.parameter))
(optional_parameter_declaration (optional_parameter_declaration
declarator: (identifier) @local.definition.parameter) declarator: (identifier) @local.definition.parameter)
;; Class / struct definitions
; Class / struct definitions
(class_specifier) @local.scope (class_specifier) @local.scope
(reference_declarator (reference_declarator
@ -16,8 +18,9 @@
(identifier) @local.definition.var) (identifier) @local.definition.var)
(struct_specifier (struct_specifier
name: (qualified_identifier name:
name: (type_identifier) @local.definition.type)) (qualified_identifier
name: (type_identifier) @local.definition.type))
(class_specifier (class_specifier
name: (type_identifier) @local.definition.type) name: (type_identifier) @local.definition.type)
@ -26,8 +29,9 @@
name: (identifier) @local.definition.type) name: (identifier) @local.definition.type)
(class_specifier (class_specifier
name: (qualified_identifier name:
name: (type_identifier) @local.definition.type)) (qualified_identifier
name: (type_identifier) @local.definition.type))
(alias_declaration (alias_declaration
name: (type_identifier) @local.definition.type) name: (type_identifier) @local.definition.type)
@ -35,9 +39,10 @@
;template <typename T> ;template <typename T>
(type_parameter_declaration (type_parameter_declaration
(type_identifier) @local.definition.type) (type_identifier) @local.definition.type)
(template_declaration) @local.scope (template_declaration) @local.scope
;; Namespaces ; Namespaces
(namespace_definition (namespace_definition
name: (namespace_identifier) @local.definition.namespace name: (namespace_identifier) @local.definition.namespace
body: (_) @local.scope) body: (_) @local.scope)
@ -47,9 +52,9 @@
body: (_) @local.scope) body: (_) @local.scope)
((namespace_identifier) @local.reference ((namespace_identifier) @local.reference
(#set! reference.kind "namespace")) (#set! reference.kind "namespace"))
;; Function definitions ; Function definitions
(template_function (template_function
name: (identifier) @local.definition.function) @local.scope name: (identifier) @local.definition.function) @local.scope
@ -57,16 +62,18 @@
name: (field_identifier) @local.definition.method) @local.scope name: (field_identifier) @local.definition.method) @local.scope
(function_declarator (function_declarator
declarator: (qualified_identifier declarator:
name: (identifier) @local.definition.function)) @local.scope (qualified_identifier
name: (identifier) @local.definition.function)) @local.scope
(field_declaration (field_declaration
declarator: (function_declarator declarator:
(field_identifier) @local.definition.method)) (function_declarator
(field_identifier) @local.definition.method))
(lambda_expression) @local.scope (lambda_expression) @local.scope
;; Control structures ; Control structures
(try_statement (try_statement
body: (_) @local.scope) body: (_) @local.scope)

View file

@ -1,3 +1 @@
[ (rule_set) @fold
(rule_set)
] @fold

View file

@ -1,92 +1,99 @@
[ [
"@media" "@media"
"@charset" "@charset"
"@namespace" "@namespace"
"@supports" "@supports"
"@keyframes" "@keyframes"
(at_keyword) (at_keyword)
(to) (to)
(from) (from)
] @keyword ] @keyword
"@import" @keyword.import "@import" @keyword.import
(comment) @comment @spell (comment) @comment @spell
[ [
(tag_name) (tag_name)
(nesting_selector) (nesting_selector)
(universal_selector) (universal_selector)
] @type ] @type
(function_name) @function (function_name) @function
[ [
"~" "~"
">" ">"
"+" "+"
"-" "-"
"*" "*"
"/" "/"
"=" "="
"^=" "^="
"|=" "|="
"~=" "~="
"$=" "$="
"*=" "*="
] @operator ] @operator
[ [
"and" "and"
"or" "or"
"not" "not"
"only" "only"
] @keyword.operator ] @keyword.operator
(important) @type.qualifier (important) @type.qualifier
(attribute_selector (plain_value) @string) (attribute_selector
(pseudo_element_selector "::" (tag_name) @property) (plain_value) @string)
(pseudo_class_selector (class_name) @property)
(pseudo_element_selector
"::"
(tag_name) @property)
(pseudo_class_selector
(class_name) @property)
[ [
(class_name) (class_name)
(id_name) (id_name)
(property_name) (property_name)
(feature_name) (feature_name)
(attribute_name) (attribute_name)
] @property ] @property
(namespace_name) @module (namespace_name) @module
((property_name) @type.definition ((property_name) @type.definition
(#lua-match? @type.definition "^[-][-]")) (#lua-match? @type.definition "^[-][-]"))
((plain_value) @type ((plain_value) @type
(#lua-match? @type "^[-][-]")) (#lua-match? @type "^[-][-]"))
[ [
(string_value) (string_value)
(color_value) (color_value)
(unit) (unit)
] @string ] @string
[ [
(integer_value) (integer_value)
(float_value) (float_value)
] @number ] @number
[ [
"#" "#"
"," ","
"." "."
":" ":"
"::" "::"
";" ";"
] @punctuation.delimiter ] @punctuation.delimiter
[ [
"{" "{"
")" ")"
"(" "("
"}" "}"
] @punctuation.bracket ] @punctuation.bracket

View file

@ -3,7 +3,9 @@
(declaration) (declaration)
] @indent.begin ] @indent.begin
(block ("}") @indent.branch) (block
("}") @indent.branch)
("}") @indent.dedent ("}") @indent.dedent
(comment) @indent.ignore (comment) @indent.ignore

View file

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

View file

@ -1,3 +1,2 @@
; inherits: tsv ; inherits: tsv
"," @punctuation.delimiter "," @punctuation.delimiter

View file

@ -1,6 +1,8 @@
; inherits: cpp ; inherits: cpp
[
[ "<<<" ">>>" ] @punctuation.bracket "<<<"
">>>"
] @punctuation.bracket
[ [
"__host__" "__host__"

View file

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

View file

@ -1,49 +1,41 @@
; Includes ; Includes
[ [
"package" "package"
"import" "import"
] @keyword.import ] @keyword.import
; Namespaces ; Namespaces
(package_identifier) @module (package_identifier) @module
(import_spec ["." "_"] @punctuation.special) (import_spec
[
"."
"_"
] @punctuation.special)
[ [
(attr_path) (attr_path)
(package_path) (package_path)
] @string.special.url ;; In attributes ] @string.special.url ; In attributes
; Attributes ; Attributes
(attribute) @attribute (attribute) @attribute
; Conditionals ; Conditionals
"if" @keyword.conditional "if" @keyword.conditional
; Repeats ; Repeats
"for" @keyword.repeat
[ (for_clause
"for" "_" @punctuation.special)
] @keyword.repeat
(for_clause "_" @punctuation.special)
; Keywords ; Keywords
"let" @keyword
[ "in" @keyword.operator
"let"
] @keyword
[
"in"
] @keyword.operator
; Operators ; Operators
[ [
"+" "+"
"-" "-"
@ -66,34 +58,33 @@
] @operator ] @operator
; Fields & Properties ; Fields & Properties
(field
(field (label
(label (identifier) @variable.member))
(identifier) @variable.member))
(selector_expression (selector_expression
(_) (_)
(identifier) @property) (identifier) @property)
; Functions ; Functions
(call_expression (call_expression
function: (identifier) @function.call) function: (identifier) @function.call)
(call_expression (call_expression
function: (selector_expression function:
(_) (selector_expression
(identifier) @function.call)) (_)
(identifier) @function.call))
(call_expression (call_expression
function: (builtin_function) @function.call) function: (builtin_function) @function.call)
(builtin_function) @function.builtin (builtin_function) @function.builtin
; Variables ; Variables
(identifier) @variable (identifier) @variable
; Types ; Types
(primitive_type) @type.builtin (primitive_type) @type.builtin
((identifier) @type ((identifier) @type
@ -102,22 +93,33 @@
[ [
(slice_type) (slice_type)
(pointer_type) (pointer_type)
] @type ;; In attributes ] @type ; In attributes
; Punctuation ; Punctuation
[ [
"," ","
":" ":"
] @punctuation.delimiter ] @punctuation.delimiter
[ "{" "}" ] @punctuation.bracket [
"{"
"}"
] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket [
"["
"]"
] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket [
"("
")"
] @punctuation.bracket
[ "<" ">" ] @punctuation.bracket [
"<"
">"
] @punctuation.bracket
[ [
(ellipsis) (ellipsis)
@ -125,7 +127,6 @@
] @punctuation.special ] @punctuation.special
; Literals ; Literals
(string) @string (string) @string
[ [
@ -150,11 +151,15 @@
] @constant.builtin ] @constant.builtin
; Interpolations ; Interpolations
(interpolation
"\\(" @punctuation.special
(_)
")" @punctuation.special) @none
(interpolation "\\(" @punctuation.special (_) ")" @punctuation.special) @none (interpolation
"\\("
(interpolation "\\(" (identifier) @variable ")") (identifier) @variable
")")
; Comments ; Comments
(comment) @comment @spell (comment) @comment @spell

View file

@ -9,11 +9,20 @@
")" ")"
] @indent.end ] @indent.end
[ "{" "}" ] @indent.branch [
"{"
"}"
] @indent.branch
[ "[" "]" ] @indent.branch [
"["
"]"
] @indent.branch
[ "(" ")" ] @indent.branch [
"("
")"
] @indent.branch
[ [
(ERROR) (ERROR)

View file

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

View file

@ -1,5 +1,4 @@
; Scopes ; Scopes
[ [
(source_file) (source_file)
(field) (field)
@ -7,17 +6,15 @@
] @local.scope ] @local.scope
; References ; References
(identifier) @local.reference (identifier) @local.reference
; Definitions ; Definitions
(import_spec (import_spec
path: (string) @local.definition.import) path: (string) @local.definition.import)
(field (field
(label (label
(identifier) @local.definition.field)) (identifier) @local.definition.field))
(package_identifier) @local.definition.namespace (package_identifier) @local.definition.namespace

View file

@ -1,5 +1,4 @@
;; Misc ; Misc
[ [
(line_comment) (line_comment)
(block_comment) (block_comment)
@ -8,6 +7,7 @@
((line_comment) @comment.documentation ((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]")) (#lua-match? @comment.documentation "^///[^/]"))
((line_comment) @comment.documentation ((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///$")) (#lua-match? @comment.documentation "^///$"))
@ -18,9 +18,12 @@
(#lua-match? @comment.documentation "^/[+][+][^+].*[+]/$")) (#lua-match? @comment.documentation "^/[+][+][^+].*[+]/$"))
[ [
"(" ")" "("
"[" "]" ")"
"{" "}" "["
"]"
"{"
"}"
] @punctuation.bracket ] @punctuation.bracket
[ [
@ -35,8 +38,7 @@
"$" "$"
] @punctuation.special ] @punctuation.special
;; Constants ; Constants
[ [
"__FILE_FULL_PATH__" "__FILE_FULL_PATH__"
"__FILE__" "__FILE__"
@ -66,11 +68,9 @@
"false" "false"
] @boolean ] @boolean
;; Functions ; Functions
(func_declarator (func_declarator
(identifier) @function (identifier) @function)
)
[ [
"__traits" "__traits"
@ -83,29 +83,22 @@
] @function.builtin ] @function.builtin
(import_expression (import_expression
"import" @function.builtin "import" @function.builtin)
)
(parameter (parameter
(var_declarator (var_declarator
(identifier) @variable.parameter (identifier) @variable.parameter))
)
)
(function_literal (function_literal
(identifier) @variable.parameter (identifier) @variable.parameter)
)
(constructor (constructor
"this" @constructor "this" @constructor)
)
(destructor (destructor
"this" @constructor "this" @constructor)
)
;; Keywords
; Keywords
[ [
"case" "case"
"default" "default"
@ -238,51 +231,45 @@
] @type.qualifier ] @type.qualifier
(alias_assignment (alias_assignment
. (identifier) @type.definition) .
(identifier) @type.definition)
(module_declaration (module_declaration
"module" @keyword.import "module" @keyword.import)
)
(import_declaration (import_declaration
"import" @keyword.import "import" @keyword.import)
)
(type) @type (type) @type
(catch_parameter (catch_parameter
(qualified_identifier) @type (qualified_identifier) @type)
)
(var_declarations (var_declarations
(qualified_identifier) @type (qualified_identifier) @type)
)
(func_declaration (func_declaration
(qualified_identifier) @type (qualified_identifier) @type)
)
(parameter (parameter
(qualified_identifier) @type (qualified_identifier) @type)
)
(class_declaration (class_declaration
(identifier) @type (identifier) @type)
)
(fundamental_type) @type.builtin (fundamental_type) @type.builtin
(module_fully_qualified_name (packages (package_name) @module)) (module_fully_qualified_name
(packages
(package_name) @module))
(module_name) @module (module_name) @module
(at_attribute) @attribute (at_attribute) @attribute
(user_defined_attribute (user_defined_attribute
"@" @attribute "@" @attribute)
)
;; Variables
; Variables
(primary_expression (primary_expression
"this" @variable.builtin "this" @variable.builtin)
)

View file

@ -5,9 +5,12 @@
] @indent.begin ] @indent.begin
[ [
"(" ")" "("
"{" "}" ")"
"[" "]" "{"
"}"
"["
"]"
] @indent.branch ] @indent.branch
[ [

View file

@ -2,8 +2,8 @@
(line_comment) (line_comment)
(block_comment) (block_comment)
(nesting_block_comment) (nesting_block_comment)
] @injection.content ] @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))
((token_string_tokens) @injection.content ((token_string_tokens) @injection.content
(#set! injection.language "d")) (#set! injection.language "d"))

Some files were not shown because too many files have changed in this diff Show more