1

Regenerate nvim config

This commit is contained in:
2024-06-02 03:29:20 +02:00
parent 75eea0c030
commit ef2e28883d
5576 changed files with 604886 additions and 503 deletions

View File

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

View File

@ -0,0 +1,286 @@
; highlight 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
; for a list of recommended @ tags, though not all of them have matching
; highlights in neovim.
[
"abort"
"abs"
"abstract"
"accept"
"access"
"all"
"array"
"at"
"begin"
"body"
"declare"
"delay"
"delta"
"digits"
"do"
"end"
"entry"
"exit"
"generic"
"interface"
"is"
"limited"
"mod"
"new"
"null"
"of"
"others"
"out"
"overriding"
"package"
"pragma"
"private"
"protected"
"range"
"separate"
"subtype"
"synchronized"
"tagged"
"task"
"terminate"
"type"
"until"
"when"
] @keyword
"record" @keyword.type
[
"aliased"
"constant"
"renames"
] @keyword.modifier
[
"with"
"use"
] @keyword.import
[
"function"
"procedure"
] @keyword.function
[
"and"
"in"
"not"
"or"
"xor"
] @keyword.operator
[
"while"
"loop"
"for"
"parallel"
"reverse"
"some"
] @keyword.repeat
"return" @keyword.return
[
"case"
"if"
"else"
"then"
"elsif"
"select"
] @keyword.conditional
[
"exception"
"raise"
] @keyword.exception
(comment) @comment @spell
(string_literal) @string
(character_literal) @string
(numeric_literal) @number
; Highlight the name of subprograms
(procedure_specification
name: (_) @function)
(function_specification
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
(use_clause
"use" @keyword.import
"type" @keyword.import)
(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
(function_specification)
"is"
(_) @attribute)
(subprogram_declaration
(aspect_specification) @attribute)
; Highlight full subprogram specifications
;(subprogram_body
; [
; (procedure_specification)
; (function_specification)
; ] @function.spec
;)
((comment) @comment.documentation
.
[
(entry_declaration)
(subprogram_declaration)
(parameter_specification)
])
(compilation_unit
.
(comment) @comment.documentation)
(component_list
(component_declaration)
.
(comment) @comment.documentation)
(enumeration_type_definition
(identifier)
.
(comment) @comment.documentation)

View File

@ -0,0 +1,91 @@
; Better highlighting by referencing to the definition, for variable
; references. However, this is not yet supported by neovim
; See https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables
(compilation) @local.scope
(package_declaration) @local.scope
(package_body) @local.scope
(subprogram_declaration) @local.scope
(subprogram_body) @local.scope
(block_statement) @local.scope
(with_clause
(identifier) @local.definition.import)
(procedure_specification
name: (_) @local.definition.function)
(function_specification
name: (_) @local.definition.function)
(package_declaration
name: (_) @local.definition.var)
(package_body
name: (_) @local.definition.var)
(generic_instantiation
.
name: (_) @local.definition.var)
(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

View File

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

View File

@ -0,0 +1,87 @@
; Constants
(integer) @number
; Variables and Symbols
(typed_binding
(atom
(qid) @variable))
(untyped_binding) @variable
(typed_binding
(expr) @type)
(id) @function
(bid) @function
(function_name
(atom
(qid) @function))
(field_name) @function
[
(data_name)
(record_name)
] @constructor
; Set
(SetN) @type.builtin
(expr
.
(atom) @function)
((atom) @boolean
(#any-of? @boolean "true" "false" "True" "False"))
; Imports and Module Declarations
"import" @keyword.import
(module_name) @module
; Pragmas and comments
(pragma) @keyword.directive
(comment) @comment @spell
; Keywords
[
"where"
"data"
"rewrite"
"postulate"
"public"
"private"
"tactic"
"Prop"
"quote"
"renaming"
"open"
"in"
"hiding"
"constructor"
"abstract"
"let"
"field"
"mutual"
"module"
"infix"
"infixl"
"infixr"
] @keyword
"record" @keyword.type
;(expr
; f_name: (atom) @function)
; Brackets
[
"("
")"
"{"
"}"
] @punctuation.bracket
"=" @operator

View File

@ -0,0 +1 @@
; inherits: html

View File

@ -0,0 +1,150 @@
; inherits: html_tags
(identifier) @variable
(pipe_operator) @operator
[
(string)
(static_member_expression)
] @string
(number) @number
(pipe_call
name: (identifier) @function)
(pipe_call
arguments: (pipe_arguments
(identifier) @variable.parameter))
(structural_directive
"*" @keyword
(identifier) @keyword)
(attribute
(attribute_name) @variable.member
(#lua-match? @variable.member "#.*"))
(binding_name
(identifier) @keyword)
(event_binding
(binding_name
(identifier) @keyword))
(event_binding
"\"" @punctuation.delimiter)
(property_binding
"\"" @punctuation.delimiter)
(structural_assignment
operator: (identifier) @keyword)
(member_expression
property: (identifier) @property)
(call_expression
function: (identifier) @function)
(call_expression
function: ((identifier) @function.builtin
(#eq? @function.builtin "$any")))
(pair
key: ((identifier) @variable.builtin
(#eq? @variable.builtin "$implicit")))
((control_keyword) @keyword.repeat
(#any-of? @keyword.repeat "for" "empty"))
((control_keyword) @keyword.conditional
(#any-of? @keyword.conditional "if" "else" "switch" "case" "default"))
((control_keyword) @keyword.coroutine
(#any-of? @keyword.coroutine "defer" "placeholder" "loading"))
((control_keyword) @keyword.exception
(#eq? @keyword.exception "error"))
(special_keyword) @keyword
((identifier) @boolean
(#any-of? @boolean "true" "false"))
((identifier) @variable.builtin
(#any-of? @variable.builtin "this" "$event"))
((identifier) @constant.builtin
(#eq? @constant.builtin "null"))
[
(ternary_operator)
(conditional_operator)
] @keyword.conditional.ternary
[
"("
")"
"["
"]"
"{"
"}"
"@"
"} @"
(if_end_expression)
(for_end_expression)
(switch_end_expression)
(case_end_expression)
(default_end_expression)
(defer_end_expression)
] @punctuation.bracket
(two_way_binding
[
"[("
")]"
] @punctuation.bracket)
[
"{{"
"}}"
] @punctuation.special
[
";"
"."
","
"?."
] @punctuation.delimiter
(nullish_coalescing_expression
(coalescing_operator) @operator)
(concatenation_expression
"+" @operator)
(icu_clause) @keyword.operator
(icu_category) @keyword.conditional
(binary_expression
[
"-"
"&&"
"+"
"<"
"<="
"="
"=="
"==="
"!="
"!=="
">"
">="
"*"
"/"
"||"
"%"
] @operator)

View File

@ -0,0 +1 @@
; inherits: html_tags

View File

@ -0,0 +1 @@
; inherits: html_tags

View File

@ -0,0 +1 @@
; inherits: html

View File

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

View File

@ -0,0 +1,260 @@
; inherits: soql
; Apex + SOQL
[
"["
"]"
"{"
"}"
"("
")"
] @punctuation.bracket
[
","
"."
":"
"?"
";"
] @punctuation.delimiter
; Default general color definition
(identifier) @variable
(type_identifier) @type
; Methods
(method_declaration
name: (identifier) @function.method)
(method_invocation
name: (identifier) @function.method.call)
(super) @function.builtin
; Annotations
(annotation
name: (identifier) @attribute)
; Types
(interface_declaration
name: (identifier) @type)
(class_declaration
name: (identifier) @type)
(class_declaration
(superclass) @type)
(enum_declaration
name: (identifier) @type)
(enum_constant
name: (identifier) @constant)
(type_arguments
"<" @punctuation.delimiter)
(type_arguments
">" @punctuation.delimiter)
(field_access
object: (identifier) @type)
(field_access
field: (identifier) @property)
((scoped_identifier
scope: (identifier) @type)
(#match? @type "^[A-Z]"))
((method_invocation
object: (identifier) @type)
(#match? @type "^[A-Z]"))
(method_declaration
(formal_parameters
(formal_parameter
name: (identifier) @variable.parameter)))
(constructor_declaration
name: (identifier) @constructor)
(dml_type) @function.builtin
(assignment_operator) @operator
(update_expression
[
"++"
"--"
] @operator)
(trigger_declaration
name: (identifier) @type
object: (identifier) @type
(trigger_event) @keyword
(","
(trigger_event) @keyword)*)
[
"@"
"="
"!="
"<="
">="
] @operator
(binary_expression
operator: [
">"
"<"
"=="
"==="
"!=="
"&&"
"||"
"+"
"-"
"*"
"/"
"&"
"|"
"^"
"%"
"<<"
">>"
">>>"
] @operator)
(unary_expression
operator: [
"+"
"-"
"!"
"~"
]) @operator
(map_initializer
"=>" @operator)
[
(boolean_type)
(void_type)
] @type.builtin
; Fields
(field_declaration
declarator: (variable_declarator
name: (identifier) @variable.member))
(field_access
field: (identifier) @variable.member)
; Variables
(field_declaration
(modifiers
(modifier
[
"final"
"static"
])
(modifier
[
"final"
"static"
]))
(variable_declarator
name: (identifier) @constant))
(variable_declarator
(identifier) @property)
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) ; SCREAM SNAKE CASE
(this) @variable.builtin
; Literals
[
(int)
(decimal)
(currency_literal)
] @number
(string_literal) @string
[
(line_comment)
(block_comment)
] @comment
(null_literal) @constant.builtin
; ;; Keywords
[
"abstract"
"final"
"private"
"protected"
"public"
"static"
] @keyword.modifier
[
"if"
"else"
"switch"
] @keyword.conditional
[
"for"
"while"
"do"
"break"
] @keyword.repeat
"return" @keyword.return
[
"throw"
"finally"
"try"
"catch"
] @keyword.exception
"new" @keyword.operator
[
"abstract"
"continue"
"default"
"extends"
"final"
"get"
"global"
"implements"
"instanceof"
"on"
"private"
"protected"
"public"
"set"
"static"
"testMethod"
"transient"
"trigger"
"virtual"
"when"
"with_sharing"
"without_sharing"
"inherited_sharing"
] @keyword
[
"interface"
"class"
"enum"
] @keyword.type
"System.runAs" @function.builtin

View File

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

View File

@ -0,0 +1 @@
; inherits: cpp

View File

@ -0,0 +1,53 @@
; inherits: cpp
((identifier) @function.builtin
(#any-of? @function.builtin
; Digital I/O
"digitalRead" "digitalWrite" "pinMode"
; Analog I/O
"analogRead" "analogReference" "analogWrite"
; Zero, Due & MKR Family
"analogReadResolution" "analogWriteResolution"
; Advanced I/O
"noTone" "pulseIn" "pulseInLong" "shiftIn" "shiftOut" "tone"
; Time
"delay" "delayMicroseconds" "micros" "millis"
; Math
"abs" "constrain" "map" "max" "min" "pow" "sq" "sqrt"
; Trigonometry
"cos" "sin" "tan"
; Characters
"isAlpha" "isAlphaNumeric" "isAscii" "isControl" "isDigit" "isGraph" "isHexadecimalDigit"
"isLowerCase" "isPrintable" "isPunct" "isSpace" "isUpperCase" "isWhitespace"
; Random Numbers
"random" "randomSeed"
; Bits and Bytes
"bit" "bitClear" "bitRead" "bitSet" "bitWrite" "highByte" "lowByte"
; External Interrupts
"attachInterrupt" "detachInterrupt"
; Interrupts
"interrupts" "noInterrupts"))
((identifier) @type.builtin
(#any-of? @type.builtin "Serial" "SPI" "Stream" "Wire" "Keyboard" "Mouse" "String"))
((identifier) @constant.builtin
(#any-of? @constant.builtin "HIGH" "LOW" "INPUT" "OUTPUT" "INPUT_PULLUP" "LED_BUILTIN"))
(function_definition
(function_declarator
declarator: (identifier) @function.builtin)
(#any-of? @function.builtin "loop" "setup"))
(call_expression
function: (primitive_type) @function.builtin)
(call_expression
function: (identifier) @constructor
(#any-of? @constructor "SPISettings" "String"))
(declaration
(type_identifier) @type.builtin
(function_declarator
declarator: (identifier) @constructor)
(#eq? @type.builtin "SPISettings"))

View File

@ -0,0 +1 @@
; inherits: cpp

View File

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

View File

@ -0,0 +1 @@
; inherits: cpp

View File

@ -0,0 +1,66 @@
; General
(label
[
(ident)
(word)
] @label)
(reg) @variable.builtin
(meta
kind: (_) @function.builtin)
(instruction
kind: (_) @function.builtin)
(const
name: (word) @constant)
; Comments
[
(line_comment)
(block_comment)
] @comment @spell
; Literals
(int) @number
(float) @number.float
(string) @string
; Keywords
[
"byte"
"word"
"dword"
"qword"
"ptr"
"rel"
"label"
"const"
] @keyword
; Operators & Punctuation
[
"+"
"-"
"*"
"/"
"%"
"|"
"^"
"&"
] @operator
[
"("
")"
"["
"]"
] @punctuation.bracket
[
","
":"
] @punctuation.delimiter

View File

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

View File

@ -0,0 +1 @@
; inherits: html

View File

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

View File

@ -0,0 +1 @@
; inherits: html

View File

@ -0,0 +1,32 @@
; inherits: html_tags
(frontmatter
(frontmatter_js_block) @injection.content
(#set! injection.language "typescript"))
(attribute_interpolation
(attribute_js_expr) @injection.content
(#set! injection.language "typescript"))
(attribute
(attribute_backtick_string) @injection.content
(#set! injection.language "typescript"))
(html_interpolation
(permissible_text) @injection.content
(#set! injection.language "typescript"))
(script_element
(raw_text) @injection.content
(#set! injection.language "typescript"))
(style_element
(start_tag
(attribute
(attribute_name) @_lang_attr
(quoted_attribute_value
(attribute_value) @_lang_value)))
(raw_text) @injection.content
(#eq? @_lang_attr "lang")
(#eq? @_lang_value "scss")
(#set! injection.language "scss"))

View File

@ -0,0 +1 @@
; inherits: html

View File

@ -0,0 +1,60 @@
(identifier) @function
(block
(relation
(relation_literal) @function.builtin
(identifier) @constant))
(block
(permission
(permission_literal) @variable.builtin
(identifier) @type))
; relations
(rel_expression
(identifier) @property)
(relation
(rel_expression
(hash_literal)
.
(identifier) @constant))
; permissions
(perm_expression
(identifier) @property)
(call_expression
function: (selector_expression
operand: (identifier) @constant
field: (field_identifier) @function.method))
(perm_expression
(stabby) @operator
.
(identifier) @function)
; misc
[
(plus_literal)
(minus_literal)
(amp_literal)
(pipe_literal)
] @operator
[
(true)
(false)
] @boolean
(nil) @constant.builtin
[
(caveat_literal)
(definition_literal)
] @keyword
[
(hash_literal)
(comment)
] @comment

View File

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

View File

@ -0,0 +1,199 @@
; adapted from https://github.com/Beaglefoot/tree-sitter-awk
[
(identifier)
(field_ref)
] @variable
(field_ref
(_) @variable)
; https://www.gnu.org/software/gawk/manual/html_node/Auto_002dset.html
((identifier) @constant.builtin
(#any-of? @constant.builtin
"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
((identifier) @variable.builtin
(#any-of? @variable.builtin
"BINMODE" "CONVFMT" "FIELDWIDTHS" "FPAT" "FS" "IGNORECASE" "LINT" "OFMT" "OFS" "ORS" "PREC"
"ROUNDMODE" "RS" "SUBSEP" "TEXTDOMAIN"))
(number) @number
(string) @string
(regex) @string.regexp
(escape_sequence) @string.escape
(comment) @comment @spell
((program
.
(comment) @keyword.directive @nospell)
(#lua-match? @keyword.directive "^#!/"))
(ns_qualified_name
(namespace) @module)
(ns_qualified_name
"::" @punctuation.delimiter)
(func_def
name: (_
(identifier) @function) @function)
(func_call
name: (_
(identifier) @function) @function)
(func_def
(param_list
(identifier) @variable.parameter))
[
"print"
"printf"
"getline"
] @function.builtin
[
(delete_statement)
(break_statement)
(continue_statement)
(next_statement)
(nextfile_statement)
] @keyword
[
"func"
"function"
] @keyword.function
[
"return"
"exit"
] @keyword.return
[
"do"
"while"
"for"
"in"
] @keyword.repeat
[
"if"
"else"
"switch"
"case"
"default"
] @keyword.conditional
[
"@include"
"@load"
] @keyword.import
"@namespace" @keyword.directive
[
"BEGIN"
"END"
"BEGINFILE"
"ENDFILE"
] @label
(binary_exp
[
"^"
"**"
"*"
"/"
"%"
"+"
"-"
"<"
">"
"<="
">="
"=="
"!="
"~"
"!~"
"in"
"&&"
"||"
] @operator)
(unary_exp
[
"!"
"+"
"-"
] @operator)
(assignment_exp
[
"="
"+="
"-="
"*="
"/="
"%="
"^="
] @operator)
(ternary_exp
[
"?"
":"
] @keyword.conditional.ternary)
(update_exp
[
"++"
"--"
] @operator)
(redirected_io_statement
[
">"
">>"
] @operator)
(piped_io_statement
[
"|"
"|&"
] @operator)
(piped_io_exp
[
"|"
"|&"
] @operator)
(field_ref
"$" @punctuation.delimiter)
(regex
"/" @punctuation.delimiter)
(regex_constant
"@" @punctuation.delimiter)
[
";"
","
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket

View File

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

View File

@ -0,0 +1,9 @@
[
(function_definition)
(if_statement)
(case_statement)
(for_statement)
(while_statement)
(c_style_for_statement)
(heredoc_redirect)
] @fold

View File

@ -0,0 +1,239 @@
[
"("
")"
"{"
"}"
"["
"]"
"[["
"]]"
"(("
"))"
] @punctuation.bracket
[
";"
";;"
";&"
";;&"
"&"
] @punctuation.delimiter
[
">"
">>"
"<"
"<<"
"&&"
"|"
"|&"
"||"
"="
"+="
"=~"
"=="
"!="
"&>"
"&>>"
"<&"
">&"
">|"
"<&-"
">&-"
"<<-"
"<<<"
".."
"!"
] @operator
; Do *not* spell check strings since they typically have some sort of
; interpolation in them, or, are typically used for things like filenames, URLs,
; flags and file content.
[
(string)
(raw_string)
(ansi_c_string)
(heredoc_body)
] @string
[
(heredoc_start)
(heredoc_end)
] @label
(variable_assignment
(word) @string)
(command
argument: "$" @string) ; bare dollar
(concatenation
(word) @string)
[
"if"
"then"
"else"
"elif"
"fi"
"case"
"in"
"esac"
] @keyword.conditional
[
"for"
"do"
"done"
"select"
"until"
"while"
] @keyword.repeat
[
"declare"
"typeset"
"readonly"
"local"
"unset"
"unsetenv"
] @keyword
"export" @keyword.import
"function" @keyword.function
(special_variable_name) @constant
; trap -l
((word) @constant.builtin
(#any-of? @constant.builtin
"SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT" "SIGBUS" "SIGFPE" "SIGKILL" "SIGUSR1"
"SIGSEGV" "SIGUSR2" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGSTKFLT" "SIGCHLD" "SIGCONT" "SIGSTOP"
"SIGTSTP" "SIGTTIN" "SIGTTOU" "SIGURG" "SIGXCPU" "SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH"
"SIGIO" "SIGPWR" "SIGSYS" "SIGRTMIN" "SIGRTMIN+1" "SIGRTMIN+2" "SIGRTMIN+3" "SIGRTMIN+4"
"SIGRTMIN+5" "SIGRTMIN+6" "SIGRTMIN+7" "SIGRTMIN+8" "SIGRTMIN+9" "SIGRTMIN+10" "SIGRTMIN+11"
"SIGRTMIN+12" "SIGRTMIN+13" "SIGRTMIN+14" "SIGRTMIN+15" "SIGRTMAX-14" "SIGRTMAX-13"
"SIGRTMAX-12" "SIGRTMAX-11" "SIGRTMAX-10" "SIGRTMAX-9" "SIGRTMAX-8" "SIGRTMAX-7" "SIGRTMAX-6"
"SIGRTMAX-5" "SIGRTMAX-4" "SIGRTMAX-3" "SIGRTMAX-2" "SIGRTMAX-1" "SIGRTMAX"))
((word) @boolean
(#any-of? @boolean "true" "false"))
(comment) @comment @spell
(test_operator) @operator
(command_substitution
"$(" @punctuation.special
")" @punctuation.special)
(process_substitution
[
"<("
">("
] @punctuation.special
")" @punctuation.special)
(arithmetic_expansion
[
"$(("
"(("
] @punctuation.special
"))" @punctuation.special)
(arithmetic_expansion
"," @punctuation.delimiter)
(ternary_expression
[
"?"
":"
] @keyword.conditional.ternary)
(binary_expression
operator: _ @operator)
(unary_expression
operator: _ @operator)
(postfix_expression
operator: _ @operator)
(function_definition
name: (word) @function)
(command_name
(word) @function.call)
(command_name
(word) @function.builtin
(#any-of? @function.builtin
"alias" "bg" "bind" "break" "builtin" "caller" "cd" "command" "compgen" "complete" "compopt"
"continue" "coproc" "dirs" "disown" "echo" "enable" "eval" "exec" "exit" "fc" "fg" "getopts"
"hash" "help" "history" "jobs" "kill" "let" "logout" "mapfile" "popd" "printf" "pushd" "pwd"
"read" "readarray" "return" "set" "shift" "shopt" "source" "suspend" "test" "time" "times"
"trap" "type" "typeset" "ulimit" "umask" "unalias" "wait"))
(command
argument: [
(word) @variable.parameter
(concatenation
(word) @variable.parameter)
])
(declaration_command
(word) @variable.parameter)
(unset_command
(word) @variable.parameter)
(number) @number
((word) @number
(#lua-match? @number "^[0-9]+$"))
(file_redirect
destination: (word) @variable.parameter)
(file_descriptor) @operator
(simple_expansion
"$" @punctuation.special) @none
(expansion
"${" @punctuation.special
"}" @punctuation.special) @none
(expansion
operator: _ @punctuation.special)
(expansion
"@"
.
operator: _ @character.special)
((expansion
(subscript
index: (word) @character.special))
(#any-of? @character.special "@" "*"))
"``" @punctuation.special
(variable_name) @variable
((variable_name) @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
(case_item
value: (word) @variable.parameter)
[
(regex)
(extglob_pattern)
] @string.regexp
((program
.
(comment) @keyword.directive @nospell)
(#lua-match? @keyword.directive "^#!/"))

View File

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

View File

@ -0,0 +1,14 @@
; Scopes
(function_definition) @local.scope
; Definitions
(variable_assignment
name: (variable_name) @local.definition.var)
(function_definition
name: (word) @local.definition.function)
; References
(variable_name) @local.reference
(word) @local.reference

View File

@ -0,0 +1,5 @@
[
(list)
(scope)
(cons)
] @fold

View File

@ -0,0 +1,126 @@
; Variables
(list
(symbol) @variable)
(cons
(symbol) @variable)
(scope
(symbol) @variable)
(symbind
(symbol) @variable)
; Constants
((symbol) @constant
(#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$"))
; Functions
(list
.
(symbol) @function)
; Namespaces
(symbind
(symbol) @module
.
(keyword))
; Includes
((symbol) @keyword.import
(#any-of? @keyword.import "use" "import" "load"))
; Keywords
((symbol) @keyword
(#any-of? @keyword "do" "doc"))
; Special Functions
; Keywords construct a symbol
(keyword) @constructor
((list
.
(symbol) @keyword.function
.
(symbol) @function
(symbol)? @variable.parameter)
(#any-of? @keyword.function "def" "defop" "defn" "fn"))
((cons
.
(symbol) @keyword.function
.
(symbol) @function
(symbol)? @variable.parameter)
(#any-of? @keyword.function "def" "defop" "defn" "fn"))
((symbol) @function.builtin
(#any-of? @function.builtin
"dump" "mkfs" "json" "log" "error" "now" "cons" "wrap" "unwrap" "eval" "make-scope" "bind"
"meta" "with-meta" "null?" "ignore?" "boolean?" "number?" "string?" "symbol?" "scope?" "sink?"
"source?" "list?" "pair?" "applicative?" "operative?" "combiner?" "path?" "empty?" "thunk?" "+"
"*" "quot" "-" "max" "min" "=" ">" ">=" "<" "<=" "list->source" "across" "emit" "next"
"reduce-kv" "assoc" "symbol->string" "string->symbol" "str" "substring" "trim" "scope->list"
"string->fs-path" "string->cmd-path" "string->dir" "subpath" "path-name" "path-stem"
"with-image" "with-dir" "with-args" "with-cmd" "with-stdin" "with-env" "with-insecure"
"with-label" "with-port" "with-tls" "with-mount" "thunk-cmd" "thunk-args" "resolve" "start"
"addr" "wait" "read" "cache-dir" "binds?" "recall-memo" "store-memo" "mask" "list" "list*"
"first" "rest" "length" "second" "third" "map" "map-pairs" "foldr" "foldl" "append" "filter"
"conj" "list->scope" "merge" "apply" "id" "always" "vals" "keys" "memo" "succeeds?" "run" "last"
"take" "take-all" "insecure!" "from" "cd" "wrap-cmd" "mkfile" "path-base" "not"))
((symbol) @function.macro
(#any-of? @function.macro
"op" "current-scope" "quote" "let" "provide" "module" "or" "and" "curryfn" "for" "$" "linux"))
; Conditionals
((symbol) @keyword.conditional
(#any-of? @keyword.conditional "if" "case" "cond" "when"))
; Repeats
((symbol) @keyword.repeat
(#any-of? @keyword.repeat "each"))
; Operators
((symbol) @operator
(#any-of? @operator "&" "*" "+" "-" "<" "<=" "=" ">" ">="))
; Punctuation
[
"("
")"
] @punctuation.bracket
[
"{"
"}"
] @punctuation.bracket
[
"["
"]"
] @punctuation.bracket
((symbol) @punctuation.delimiter
(#eq? @punctuation.delimiter "->"))
; Literals
(string) @string
(escape_sequence) @string.escape
(path) @string.special.url
(number) @number
(boolean) @boolean
[
(ignore)
(null)
] @constant.builtin
"^" @character.special
; Comments
(comment) @comment @spell

View File

@ -0,0 +1,31 @@
[
(list)
(scope)
(cons)
] @indent.begin
[
")"
"}"
"]"
] @indent.end
[
"("
")"
] @indent.branch
[
"{"
"}"
] @indent.branch
[
"["
"]"
] @indent.branch
[
(ERROR)
(comment)
] @indent.auto

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1 @@
(entry) @fold

View File

@ -0,0 +1,50 @@
; CREDITS @pfoerster (adapted from https://github.com/latex-lsp/tree-sitter-bibtex)
[
(string_type)
(preamble_type)
(entry_type)
] @keyword
[
(junk)
(comment)
] @comment
(comment) @spell
[
"="
"#"
] @operator
(command) @function.builtin
(number) @number
(field
name: (identifier) @variable.member)
(token
(identifier) @variable.parameter)
[
(brace_word)
(quote_word)
] @string
[
(key_brace)
(key_paren)
] @string.special.symbol
(string
name: (identifier) @constant)
[
"{"
"}"
"("
")"
] @punctuation.bracket
"," @punctuation.delimiter

View File

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

View File

@ -0,0 +1,19 @@
[
(module_declaration)
(metadata_declaration)
(output_declaration)
(parameter_declaration)
(resource_declaration)
(type_declaration)
(variable_declaration)
(parenthesized_expression)
(decorators)
(array)
(object)
(if_statement)
(for_statement)
(subscript_expression)
(ternary_expression)
(string)
(comment)
] @fold

View File

@ -0,0 +1,234 @@
; Includes
[
"import"
"provider"
"with"
"as"
"from"
] @keyword.import
; Namespaces
(module_declaration
(identifier) @module)
; Builtins
(primitive_type) @type.builtin
((member_expression
object: (identifier) @type.builtin)
(#eq? @type.builtin "sys"))
; Functions
(call_expression
function: (identifier) @function.call)
(user_defined_function
name: (identifier) @function)
; Properties
(object_property
(identifier) @property
":" @punctuation.delimiter
(_))
(object_property
(compatible_identifier) @property
":" @punctuation.delimiter
(_))
(property_identifier) @property
; Attributes
(decorator
"@" @attribute)
(decorator
(call_expression
(identifier) @attribute))
(decorator
(call_expression
(member_expression
object: (identifier) @attribute
property: (property_identifier) @attribute)))
; Types
(type_declaration
(identifier) @type)
(type_declaration
(identifier)
"="
(identifier) @type)
(type
(identifier) @type)
(resource_declaration
(identifier) @type)
(resource_expression
(identifier) @type)
; Parameters
(parameter_declaration
(identifier) @variable.parameter
(_))
(call_expression
function: (_)
(arguments
(identifier) @variable.parameter))
(call_expression
function: (_)
(arguments
(member_expression
object: (identifier) @variable.parameter)))
(parameter
.
(identifier) @variable.parameter)
; Variables
(variable_declaration
(identifier) @variable
(_))
(metadata_declaration
(identifier) @variable
(_))
(output_declaration
(identifier) @variable
(_))
(object_property
(_)
":"
(identifier) @variable)
(for_statement
"for"
(for_loop_parameters
(loop_variable) @variable
(loop_enumerator) @variable))
; Conditionals
"if" @keyword.conditional
(ternary_expression
"?" @keyword.conditional.ternary
":" @keyword.conditional.ternary)
; Loops
(for_statement
"for" @keyword.repeat
"in"
":" @punctuation.delimiter)
; Keywords
[
"module"
"metadata"
"output"
"param"
"resource"
"existing"
"targetScope"
"type"
"var"
"using"
"test"
] @keyword
"func" @keyword.function
"assert" @keyword.exception
; Operators
[
"+"
"-"
"*"
"/"
"%"
"||"
"&&"
"|"
"=="
"!="
"=~"
"!~"
">"
">="
"<="
"<"
"??"
"="
"!"
".?"
] @operator
(subscript_expression
"?" @operator)
(nullable_type
"?" @operator)
"in" @keyword.operator
; Literals
(string) @string
(escape_sequence) @string.escape
(number) @number
(boolean) @boolean
(null) @constant.builtin
; Misc
(compatible_identifier
"?" @punctuation.special)
(nullable_return_type) @punctuation.special
[
"{"
"}"
] @punctuation.bracket
[
"["
"]"
] @punctuation.bracket
[
"("
")"
] @punctuation.bracket
[
"."
":"
"::"
"=>"
] @punctuation.delimiter
; Interpolation
(interpolation) @none
(interpolation
"${" @punctuation.special
"}" @punctuation.special)
(interpolation
(identifier) @variable)
; Comments
[
(comment)
(diagnostic_comment)
] @comment @spell

View File

@ -0,0 +1,27 @@
[
(array)
(object)
] @indent.begin
"}" @indent.end
[
"{"
"}"
] @indent.branch
[
"["
"]"
] @indent.branch
[
"("
")"
] @indent.branch
[
(ERROR)
(comment)
(diagnostic_comment)
] @indent.auto

View File

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

View File

@ -0,0 +1,73 @@
; Scopes
[
(infrastructure)
(call_expression)
(lambda_expression)
(subscript_expression)
(if_statement)
(for_statement)
(array)
(object)
(interpolation)
] @local.scope
; References
(property_identifier) @local.reference
(call_expression
(identifier) @local.reference)
(object_property
(_)
":"
(identifier) @local.reference)
(resource_expression
(identifier) @local.reference)
; Definitions
(type) @local.definition.associated
(object_property
(identifier) @local.definition.field
(_))
(object_property
(compatible_identifier) @local.definition.field
(_))
(user_defined_function
name: (identifier) @local.definition.function)
(module_declaration
(identifier) @local.definition.namespace)
(parameter_declaration
(identifier) @local.definition.parameter
(_))
(parameter
.
(identifier) @local.definition.parameter)
(type_declaration
(identifier) @local.definition.type
(_))
(variable_declaration
(identifier) @local.definition.var
(_))
(metadata_declaration
(identifier) @local.definition.var
(_))
(output_declaration
(identifier) @local.definition.var
(_))
(for_statement
"for"
(for_loop_parameters
(loop_variable) @local.definition.var
(loop_enumerator) @local.definition.var))

View File

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

View File

@ -0,0 +1,407 @@
; Includes
[
"inherit"
"include"
"require"
"export"
"import"
] @keyword.import
; Keywords
[
"unset"
"EXPORT_FUNCTIONS"
"python"
"assert"
"exec"
"global"
"nonlocal"
"pass"
"print"
"with"
"as"
] @keyword
[
"async"
"await"
] @keyword.coroutine
[
"return"
"yield"
] @keyword.return
(yield
"from" @keyword.return)
(future_import_statement
"from" @keyword.import
"__future__" @constant.builtin)
(import_from_statement
"from" @keyword.import)
"import" @keyword.import
(aliased_import
"as" @keyword.import)
[
"if"
"elif"
"else"
] @keyword.conditional
[
"for"
"while"
"break"
"continue"
] @keyword.repeat
[
"try"
"except"
"except*"
"raise"
"finally"
] @keyword.exception
(raise_statement
"from" @keyword.exception)
(try_statement
(else_clause
"else" @keyword.exception))
[
"addtask"
"deltask"
"addhandler"
"def"
"lambda"
] @keyword.function
[
"before"
"after"
] @keyword.modifier
[
"append"
"prepend"
"remove"
] @keyword.modifier
; Variables
[
(identifier)
(python_identifier)
] @variable
[
"noexec"
"INHERIT"
"OVERRIDES"
"$BB_ENV_PASSTHROUGH"
"$BB_ENV_PASSTHROUGH_ADDITIONS"
] @variable.builtin
; Reset highlighting in f-string interpolations
(interpolation) @none
; Identifier naming conventions
((python_identifier) @type
(#lua-match? @type "^[A-Z].*[a-z]"))
([
(identifier)
(python_identifier)
] @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
((python_identifier) @constant.builtin
(#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
((python_identifier) @constant.builtin
(#any-of? @constant.builtin
; https://docs.python.org/3/library/constants.html
"NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license"))
((assignment
left: (python_identifier) @type.definition
(type
(python_identifier) @_annotation))
(#eq? @_annotation "TypeAlias"))
((assignment
left: (python_identifier) @type.definition
right: (call
function: (python_identifier) @_func))
(#any-of? @_func "TypeVar" "NewType"))
; Fields
(flag) @variable.member
((attribute
attribute: (python_identifier) @variable.member)
(#lua-match? @variable.member "^[%l_].*$"))
; Functions
(call
function: (python_identifier) @function.call)
(call
function: (attribute
attribute: (python_identifier) @function.method.call))
((call
function: (python_identifier) @constructor)
(#lua-match? @constructor "^%u"))
((call
function: (attribute
attribute: (python_identifier) @constructor))
(#lua-match? @constructor "^%u"))
((call
function: (python_identifier) @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__"))
(python_function_definition
name: (python_identifier) @function)
(type
(python_identifier) @type)
(type
(subscript
(python_identifier) @type)) ; type subscript: Tuple[int]
((call
function: (python_identifier) @_isinstance
arguments: (argument_list
(_)
(python_identifier) @type))
(#eq? @_isinstance "isinstance"))
(anonymous_python_function
(identifier) @function)
(function_definition
(identifier) @function)
(addtask_statement
(identifier) @function)
(deltask_statement
(identifier) @function)
(export_functions_statement
(identifier) @function)
(addhandler_statement
(identifier) @function)
(python_function_definition
body: (block
.
(expression_statement
(python_string) @string.documentation @spell)))
; Namespace
(inherit_path) @module
; Normal parameters
(parameters
(python_identifier) @variable.parameter)
; Lambda parameters
(lambda_parameters
(python_identifier) @variable.parameter)
(lambda_parameters
(tuple_pattern
(python_identifier) @variable.parameter))
; Default parameters
(keyword_argument
name: (python_identifier) @variable.parameter)
; Naming parameters on call-site
(default_parameter
name: (python_identifier) @variable.parameter)
(typed_parameter
(python_identifier) @variable.parameter)
(typed_default_parameter
(python_identifier) @variable.parameter)
; Variadic parameters *args, **kwargs
(parameters
(list_splat_pattern
; *args
(python_identifier) @variable.parameter))
(parameters
(dictionary_splat_pattern
; **kwargs
(python_identifier) @variable.parameter))
; Literals
(none) @constant.builtin
[
(true)
(false)
] @boolean
((python_identifier) @variable.builtin
(#any-of? @variable.builtin "self" "cls"))
(integer) @number
(float) @number.float
; Operators
[
"?="
"??="
":="
"=+"
".="
"=."
"-"
"-="
":="
"!="
"*"
"**"
"**="
"*="
"/"
"//"
"//="
"/="
"&"
"&="
"%"
"%="
"^"
"^="
"+"
"+="
"<"
"<<"
"<<="
"<="
"<>"
"="
"=="
">"
">="
">>"
">>="
"@"
"@="
"|"
"|="
"~"
"->"
] @operator
[
"and"
"in"
"is"
"not"
"or"
"is not"
"not in"
"del"
] @keyword.operator
; Literals
[
(string)
(python_string)
"\""
] @string
(include_path) @string.special.path
[
(escape_sequence)
(escape_interpolation)
] @string.escape
; Punctuation
[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
[
":"
"->"
";"
"."
","
(ellipsis)
] @punctuation.delimiter
(variable_expansion
[
"${"
"}"
] @punctuation.special)
(inline_python
[
"${@"
"}"
] @punctuation.special)
(interpolation
"{" @punctuation.special
"}" @punctuation.special)
(type_conversion) @function.macro
([
(identifier)
(python_identifier)
] @type.builtin
(#any-of? @type.builtin
; https://docs.python.org/3/library/exceptions.html
"BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError"
"AttributeError" "EOFError" "FloatingPointError" "GeneratorExit" "ImportError"
"ModuleNotFoundError" "IndexError" "KeyError" "KeyboardInterrupt" "MemoryError" "NameError"
"NotImplementedError" "OSError" "OverflowError" "RecursionError" "ReferenceError" "RuntimeError"
"StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError" "SystemError"
"SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError"
"UnicodeDecodeError" "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError"
"IOError" "WindowsError" "BlockingIOError" "ChildProcessError" "ConnectionError"
"BrokenPipeError" "ConnectionAbortedError" "ConnectionRefusedError" "ConnectionResetError"
"FileExistsError" "FileNotFoundError" "InterruptedError" "IsADirectoryError"
"NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning"
"UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning"
"FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning"
; https://docs.python.org/3/library/stdtypes.html
"bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview"
"set" "frozenset" "dict" "type" "object"))
(comment) @comment @spell

View File

@ -0,0 +1,172 @@
[
(import_from_statement)
(parenthesized_expression)
(generator_expression)
(list_comprehension)
(set_comprehension)
(dictionary_comprehension)
(tuple_pattern)
(list_pattern)
(binary_operator)
(lambda)
(concatenated_string)
] @indent.begin
((list) @indent.align
(#set! indent.open_delimiter "[")
(#set! indent.close_delimiter "]"))
((dictionary) @indent.align
(#set! indent.open_delimiter "{")
(#set! indent.close_delimiter "}"))
((set) @indent.align
(#set! indent.open_delimiter "{")
(#set! indent.close_delimiter "}"))
((for_statement) @indent.begin
(#set! indent.immediate 1))
((if_statement) @indent.begin
(#set! indent.immediate 1))
((while_statement) @indent.begin
(#set! indent.immediate 1))
((try_statement) @indent.begin
(#set! indent.immediate 1))
(ERROR
"try"
":" @indent.begin
(#set! indent.immediate 1))
((python_function_definition) @indent.begin
(#set! indent.immediate 1))
(function_definition) @indent.begin
(anonymous_python_function) @indent.begin
((with_statement) @indent.begin
(#set! indent.immediate 1))
(if_statement
condition: (parenthesized_expression) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1))
(while_statement
condition: (parenthesized_expression) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1))
(ERROR
"(" @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
.
(_))
((argument_list) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
((parameters) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")")
(#set! indent.avoid_last_matching_next 1))
((tuple) @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)
(continue_statement)
] @indent.dedent
(ERROR
(_) @indent.branch
":"
.
(#lua-match? @indent.branch "^else"))
(ERROR
(_) @indent.branch @indent.dedent
":"
.
(#lua-match? @indent.branch "^elif"))
(parenthesized_expression
")" @indent.end)
(generator_expression
")" @indent.end)
(list_comprehension
"]" @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
[
(_) @indent.end
(_
[
(_)
")"
"}"
"]"
] @indent.end .)
(attribute
attribute: (_) @indent.end)
(call
arguments: (_
")" @indent.end))
"return" @indent.end
] .)
[
")"
"]"
"}"
(elif_clause)
(else_clause)
(except_clause)
(finally_clause)
] @indent.branch
(string) @indent.auto

View File

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

View File

@ -0,0 +1,117 @@
; References
[
(python_identifier)
(identifier)
] @local.reference
; Imports
(aliased_import
alias: (python_identifier) @local.definition.import)
(import_statement
name: (dotted_name
(python_identifier) @local.definition.import))
(import_from_statement
name: (dotted_name
(python_identifier) @local.definition.import))
; Function with parameters, defines parameters
(parameters
(python_identifier) @local.definition.parameter)
(default_parameter
(python_identifier) @local.definition.parameter)
(typed_parameter
(python_identifier) @local.definition.parameter)
(typed_default_parameter
(python_identifier) @local.definition.parameter)
; *args parameter
(parameters
(list_splat_pattern
(python_identifier) @local.definition.parameter))
; **kwargs parameter
(parameters
(dictionary_splat_pattern
(python_identifier) @local.definition.parameter))
; Function defines function and scope
((python_function_definition
name: (python_identifier) @local.definition.function) @local.scope
(#set! definition.function.scope "parent"))
(function_definition
(identifier) @local.definition.function)
(anonymous_python_function
(identifier) @local.definition.function)
; Loops
; not a scope!
(for_statement
left: (pattern_list
(python_identifier) @local.definition.var))
(for_statement
left: (tuple_pattern
(python_identifier) @local.definition.var))
(for_statement
left: (python_identifier) @local.definition.var)
; not a scope!
;(while_statement) @local.scope
; for in list comprehension
(for_in_clause
left: (python_identifier) @local.definition.var)
(for_in_clause
left: (tuple_pattern
(python_identifier) @local.definition.var))
(for_in_clause
left: (pattern_list
(python_identifier) @local.definition.var))
(dictionary_comprehension) @local.scope
(list_comprehension) @local.scope
(set_comprehension) @local.scope
; Assignments
(assignment
left: (python_identifier) @local.definition.var)
(assignment
left: (pattern_list
(python_identifier) @local.definition.var))
(assignment
left: (tuple_pattern
(python_identifier) @local.definition.var))
(assignment
left: (attribute
(python_identifier)
(python_identifier) @local.definition.field))
(variable_assignment
(identifier)
operator: [
"="
"?="
"??="
":="
] @local.definition.var)
; Walrus operator x := 1
(named_expression
(python_identifier) @local.definition.var)
(as_pattern
alias: (as_pattern_target) @local.definition.var)

View File

@ -0,0 +1,75 @@
(object_id) @variable
(string) @string
(escape_sequence) @string.escape
(comment) @comment @spell
(constant) @constant.builtin
(boolean) @boolean
(using) @keyword.import
(template) @keyword
(decorator) @attribute
(property_definition
(property_name) @property)
(object) @type
(signal_binding
(signal_name) @function.builtin)
(signal_binding
(function
(identifier)) @function)
(signal_binding
"swapped" @keyword)
(styles_list
"styles" @function.macro)
(layout_definition
"layout" @function.macro)
(gettext_string
"_" @function.builtin)
(menu_definition
"menu" @keyword)
(menu_section
"section" @keyword)
(menu_item
"item" @function.macro)
(import_statement
(gobject_library) @module)
(import_statement
(version_number) @number.float)
(float) @number.float
(number) @number
[
";"
"."
","
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket

View File

@ -0,0 +1,6 @@
[
(list_expression)
(map_expression)
(module)
(select_expression)
] @fold

View File

@ -0,0 +1,55 @@
(comment) @comment @spell
(operator) @operator
(integer_literal
"-" @operator)
[
","
":"
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
(boolean_literal) @boolean
(integer_literal) @number
[
(raw_string_literal)
(interpreted_string_literal)
] @string
(escape_sequence) @string.escape
(identifier) @variable
(module
type: (identifier) @function.call)
(module
(property
field: (identifier) @variable.parameter))
[
(unset)
(default)
] @variable.builtin
(condition
name: (identifier) @function.builtin)
(map_expression
(property
field: (identifier) @property))
(select_expression
"select" @keyword.conditional)

View File

@ -0,0 +1,38 @@
(list_expression) @indent.begin
(list_expression
"]" @indent.branch)
(map_expression) @indent.begin
(map_expression
"}" @indent.branch)
(select_expression) @indent.begin
(select_expression
")" @indent.branch)
(select_value) @indent.begin
(select_value
")" @indent.branch)
(select_pattern
"(" @indent.begin)
(select_pattern
")" @indent.branch)
(select_cases) @indent.begin
(select_cases
"}" @indent.branch)
(module) @indent.begin
(module
")" @indent.branch)
(module
"}" @indent.branch)

View File

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

View File

@ -0,0 +1,12 @@
(module
(property
field: (identifier) @local.definition.parameter))
(map_expression
(property
field: (identifier) @local.definition.field))
(assignment
left: (identifier) @local.definition.var)
(identifier) @local.reference

View File

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

View File

@ -0,0 +1,332 @@
; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration.
((identifier) @variable
(#set! "priority" 95))
(preproc_def
(preproc_arg) @variable)
[
"default"
"goto"
"asm"
"__asm__"
] @keyword
[
"enum"
"struct"
"union"
"typedef"
] @keyword.type
[
"sizeof"
"offsetof"
] @keyword.operator
(alignof_expression
.
_ @keyword.operator)
"return" @keyword.return
[
"while"
"for"
"do"
"continue"
"break"
] @keyword.repeat
[
"if"
"else"
"case"
"switch"
] @keyword.conditional
[
"#if"
"#ifdef"
"#ifndef"
"#else"
"#elif"
"#endif"
"#elifdef"
"#elifndef"
(preproc_directive)
] @keyword.directive
"#define" @keyword.directive.define
"#include" @keyword.import
[
";"
":"
","
"::"
] @punctuation.delimiter
"..." @punctuation.special
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
[
"="
"-"
"*"
"/"
"+"
"%"
"~"
"|"
"&"
"^"
"<<"
">>"
"->"
"."
"<"
"<="
">="
">"
"=="
"!="
"!"
"&&"
"||"
"-="
"+="
"*="
"/="
"%="
"|="
"&="
"^="
">>="
"<<="
"--"
"++"
] @operator
; Make sure the comma operator is given a highlight group after the comma
; punctuator so the operator is highlighted properly.
(comma_expression
"," @operator)
[
(true)
(false)
] @boolean
(conditional_expression
[
"?"
":"
] @keyword.conditional.ternary)
(string_literal) @string
(system_lib_string) @string
(escape_sequence) @string.escape
(null) @constant.builtin
(number_literal) @number
(char_literal) @character
(preproc_defined) @function.macro
((field_expression
(field_identifier) @property) @_parent
(#not-has-parent? @_parent template_method function_declarator call_expression))
(field_designator) @property
((field_identifier) @property
(#has-ancestor? @property field_declaration)
(#not-has-ancestor? @property function_declarator))
(statement_identifier) @label
(declaration
type: (type_identifier) @_type
declarator: (identifier) @label
(#eq? @_type "__label__"))
[
(type_identifier)
(type_descriptor)
] @type
(storage_class_specifier) @keyword.modifier
[
(type_qualifier)
(gnu_asm_qualifier)
"__extension__"
] @keyword.modifier
(linkage_specification
"extern" @keyword.modifier)
(type_definition
declarator: (type_identifier) @type.definition)
(primitive_type) @type.builtin
(sized_type_specifier
_ @type.builtin
type: _?)
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
(preproc_def
(preproc_arg) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
(enumerator
name: (identifier) @constant)
(case_statement
value: (identifier) @constant)
((identifier) @constant.builtin
; format-ignore
(#any-of? @constant.builtin
"stderr" "stdin" "stdout"
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
"__TIMESTAMP__" "__clang__" "__clang_major__"
"__clang_minor__" "__clang_patchlevel__"
"__clang_version__" "__clang_literal_encoding__"
"__clang_wide_literal_encoding__"
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
"__VA_ARGS__" "__VA_OPT__"))
(preproc_def
(preproc_arg) @constant.builtin
; format-ignore
(#any-of? @constant.builtin
"stderr" "stdin" "stdout"
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
"__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__"
"__cplusplus" "__OBJC__" "__ASSEMBLER__"
"__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__"
"__TIMESTAMP__" "__clang__" "__clang_major__"
"__clang_minor__" "__clang_patchlevel__"
"__clang_version__" "__clang_literal_encoding__"
"__clang_wide_literal_encoding__"
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
"__VA_ARGS__" "__VA_OPT__"))
(attribute_specifier
(argument_list
(identifier) @variable.builtin))
(attribute_specifier
(argument_list
(call_expression
function: (identifier) @variable.builtin)))
((call_expression
function: (identifier) @function.builtin)
(#lua-match? @function.builtin "^__builtin_"))
((call_expression
function: (identifier) @function.builtin)
(#has-ancestor? @function.builtin attribute_specifier))
; Preproc def / undef
(preproc_def
name: (_) @constant)
(preproc_call
directive: (preproc_directive) @_u
argument: (_) @constant
(#eq? @_u "#undef"))
(call_expression
function: (identifier) @function.call)
(call_expression
function: (field_expression
field: (field_identifier) @function.call))
(function_declarator
declarator: (identifier) @function)
(function_declarator
declarator: (parenthesized_declarator
(pointer_declarator
declarator: (field_identifier) @function)))
(preproc_function_def
name: (identifier) @function.macro)
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
; Parameters
(parameter_declaration
declarator: (identifier) @variable.parameter)
(parameter_declaration
declarator: (array_declarator) @variable.parameter)
(parameter_declaration
declarator: (pointer_declarator) @variable.parameter)
; K&R functions
; To enable support for K&R functions,
; add the following lines to your own query config and uncomment them.
; They are commented out as they'll conflict with C++
; Note that you'll need to have `; extends` at the top of your query file.
;
; (parameter_list (identifier) @variable.parameter)
;
; (function_definition
; declarator: _
; (declaration
; declarator: (identifier) @variable.parameter))
;
; (function_definition
; declarator: _
; (declaration
; declarator: (array_declarator) @variable.parameter))
;
; (function_definition
; declarator: _
; (declaration
; declarator: (pointer_declarator) @variable.parameter))
(preproc_params
(identifier) @variable.parameter)
[
"__attribute__"
"__declspec"
"__based"
"__cdecl"
"__clrcall"
"__stdcall"
"__fastcall"
"__thiscall"
"__vectorcall"
(ms_pointer_modifier)
(attribute_declaration)
] @attribute

View File

@ -0,0 +1,99 @@
[
(compound_statement)
(field_declaration_list)
(case_statement)
(enumerator_list)
(compound_literal_expression)
(initializer_list)
(init_declarator)
] @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
; So narrow indent capture to check for error inside expression statement only,
(expression_statement
(_) @indent.begin
";" @indent.end)
(ERROR
"for"
"(" @indent.begin
";"
";"
")" @indent.end)
((for_statement
body: (_) @_body) @indent.begin
(#not-has-type? @_body compound_statement))
(while_statement
condition: (_) @indent.begin)
((while_statement
body: (_) @_body) @indent.begin
(#not-has-type? @_body compound_statement))
((if_statement)
.
(ERROR
"else" @indent.begin))
(if_statement
condition: (_) @indent.begin)
; Supports if without braces (but not both if-else without braces)
(if_statement
consequence: (_
";" @indent.end) @_consequence
(#not-has-type? @_consequence compound_statement)
alternative: (else_clause
"else" @indent.branch
[
(if_statement
(compound_statement) @indent.dedent)? @indent.dedent
(compound_statement)? @indent.dedent
(_)? @indent.dedent
])?) @indent.begin
(else_clause
(_
.
"{" @indent.branch))
(compound_statement
"}" @indent.end)
[
")"
"}"
(statement_identifier)
] @indent.branch
[
"#define"
"#ifdef"
"#ifndef"
"#elif"
"#if"
"#else"
"#endif"
] @indent.zero
[
(preproc_arg)
(string_literal)
] @indent.ignore
((ERROR
(parameter_declaration)) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
([
(argument_list)
(parameter_list)
] @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
(comment) @indent.auto

View File

@ -0,0 +1,128 @@
((preproc_arg) @injection.content
(#set! injection.language "c"))
((comment) @injection.content
(#set! injection.language "comment"))
((comment) @injection.content
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
(#set! injection.language "re2c"))
((comment) @injection.content
(#lua-match? @injection.content "/[*\/][!*\/]<?[^a-zA-Z]")
(#set! injection.language "doxygen"))
((call_expression
function: (identifier) @_function
arguments: (argument_list
.
[
(string_literal
(string_content) @injection.content)
(concatenated_string
(string_literal
(string_content) @injection.content))
]))
; format-ignore
(#any-of? @_function
"printf" "printf_s"
"vprintf" "vprintf_s"
"scanf" "scanf_s"
"vscanf" "vscanf_s"
"wprintf" "wprintf_s"
"vwprintf" "vwprintf_s"
"wscanf" "wscanf_s"
"vwscanf" "vwscanf_s"
"cscanf" "_cscanf"
"printw"
"scanw")
(#set! injection.language "printf"))
((call_expression
function: (identifier) @_function
arguments: (argument_list
(_)
.
[
(string_literal
(string_content) @injection.content)
(concatenated_string
(string_literal
(string_content) @injection.content))
]))
; format-ignore
(#any-of? @_function
"fprintf" "fprintf_s"
"sprintf"
"dprintf"
"fscanf" "fscanf_s"
"sscanf" "sscanf_s"
"vsscanf" "vsscanf_s"
"vfprintf" "vfprintf_s"
"vsprintf"
"vdprintf"
"fwprintf" "fwprintf_s"
"vfwprintf" "vfwprintf_s"
"fwscanf" "fwscanf_s"
"swscanf" "swscanf_s"
"vswscanf" "vswscanf_s"
"vfscanf" "vfscanf_s"
"vfwscanf" "vfwscanf_s"
"wprintw"
"vw_printw" "vwprintw"
"wscanw"
"vw_scanw" "vwscanw")
(#set! injection.language "printf"))
((call_expression
function: (identifier) @_function
arguments: (argument_list
(_)
.
(_)
.
[
(string_literal
(string_content) @injection.content)
(concatenated_string
(string_literal
(string_content) @injection.content))
]))
; format-ignore
(#any-of? @_function
"sprintf_s"
"snprintf" "snprintf_s"
"vsprintf_s"
"vsnprintf" "vsnprintf_s"
"swprintf" "swprintf_s"
"snwprintf_s"
"vswprintf" "vswprintf_s"
"vsnwprintf_s"
"mvprintw"
"mvscanw")
(#set! injection.language "printf"))
((call_expression
function: (identifier) @_function
arguments: (argument_list
(_)
.
(_)
.
(_)
.
[
(string_literal
(string_content) @injection.content)
(concatenated_string
(string_literal
(string_content) @injection.content))
]))
(#any-of? @_function "mvwprintw" "mvwscanw")
(#set! injection.language "printf"))
; TODO: add when asm is added
; (gnu_asm_expression assembly_code: (string_literal) @injection.content
; (#set! injection.language "asm"))
; (gnu_asm_expression assembly_code: (concatenated_string (string_literal) @injection.content)
; (#set! injection.language "asm"))

View File

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

View File

@ -0,0 +1,17 @@
body: [
(declaration_list)
(switch_body)
(enum_member_declaration_list)
] @fold
accessors: (accessor_list) @fold
initializer: (initializer_expression) @fold
[
(block)
(preproc_if)
(preproc_elif)
(preproc_else)
(using_directive)+
] @fold

View File

@ -0,0 +1,579 @@
[
(identifier)
(preproc_arg)
] @variable
((preproc_arg) @constant.macro
(#lua-match? @constant.macro "^[_A-Z][_A-Z0-9]*$"))
((identifier) @keyword
(#eq? @keyword "value")
(#has-ancestor? @keyword accessor_declaration))
(method_declaration
name: (identifier) @function.method)
(local_function_statement
name: (identifier) @function.method)
(method_declaration
returns: [
(identifier) @type
(generic_name
(identifier) @type)
])
(event_declaration
type: (identifier) @type)
(event_declaration
name: (identifier) @variable.member)
(event_field_declaration
(variable_declaration
(variable_declarator
name: (identifier) @variable.member)))
(declaration_pattern
type: (identifier) @type)
(local_function_statement
type: (identifier) @type)
(interpolation) @none
(member_access_expression
name: (identifier) @variable.member)
(invocation_expression
(member_access_expression
name: (identifier) @function.method.call))
(invocation_expression
function: (conditional_access_expression
(member_binding_expression
name: (identifier) @function.method.call)))
(namespace_declaration
name: [
(qualified_name)
(identifier)
] @module)
(qualified_name
(identifier) @type)
(namespace_declaration
name: (identifier) @module)
(file_scoped_namespace_declaration
name: (identifier) @module)
(qualified_name
(identifier) @module
(#not-has-ancestor? @module method_declaration)
(#not-has-ancestor? @module record_declaration)
(#has-ancestor? @module namespace_declaration file_scoped_namespace_declaration))
(invocation_expression
(identifier) @function.method.call)
(field_declaration
(variable_declaration
(variable_declarator
(identifier) @variable.member)))
(initializer_expression
(assignment_expression
left: (identifier) @variable.member))
(parameter
name: (identifier) @variable.parameter)
(parameter_list
name: (identifier) @variable.parameter)
(bracketed_parameter_list
name: (identifier) @variable.parameter)
(implicit_parameter) @variable.parameter
(parameter_list
(parameter
type: (identifier) @type))
(integer_literal) @number
(real_literal) @number.float
(null_literal) @constant.builtin
(calling_convention
[
(identifier)
"Cdecl"
"Stdcall"
"Thiscall"
"Fastcall"
] @attribute.builtin)
(character_literal) @character
[
(string_literal)
(raw_string_literal)
(verbatim_string_literal)
(interpolated_string_expression)
] @string
(escape_sequence) @string.escape
[
"true"
"false"
] @boolean
(predefined_type) @type.builtin
(implicit_type) @keyword
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))
(using_directive
(identifier) @type)
(using_directive
(type) @type.definition)
(property_declaration
name: (identifier) @property)
(property_declaration
type: (identifier) @type)
(nullable_type
type: (identifier) @type)
(array_type
type: (identifier) @type)
(ref_type
type: (identifier) @type)
(pointer_type
type: (identifier) @type)
(catch_declaration
type: (identifier) @type)
(interface_declaration
name: (identifier) @type)
(class_declaration
name: (identifier) @type)
(record_declaration
name: (identifier) @type)
(struct_declaration
name: (identifier) @type)
(enum_declaration
name: (identifier) @type)
(enum_member_declaration
name: (identifier) @variable.member)
(operator_declaration
type: (identifier) @type)
(conversion_operator_declaration
type: (identifier) @type)
(explicit_interface_specifier
[
(identifier) @type
(generic_name
(identifier) @type)
])
(explicit_interface_specifier
(identifier) @type)
(primary_constructor_base_type
type: (identifier) @type)
[
"assembly"
"module"
"this"
"base"
(discard)
] @variable.builtin
(constructor_declaration
name: (identifier) @constructor)
(destructor_declaration
name: (identifier) @constructor)
(constructor_initializer
"base" @constructor)
(variable_declaration
(identifier) @type)
(object_creation_expression
(identifier) @type)
; Generic Types.
(typeof_expression
(generic_name
(identifier) @type))
(type_argument_list
(generic_name
(identifier) @type))
(base_list
(generic_name
(identifier) @type))
(type_parameter_constraint
[
(identifier) @type
(type
(generic_name
(identifier) @type))
])
(object_creation_expression
(generic_name
(identifier) @type))
(property_declaration
(generic_name
(identifier) @type))
(_
type: (generic_name
(identifier) @type))
; Generic Method invocation with generic type
(invocation_expression
function: (generic_name
.
(identifier) @function.method.call))
(invocation_expression
(member_access_expression
(generic_name
(identifier) @function.method)))
(base_list
(identifier) @type)
(type_argument_list
(identifier) @type)
(type_parameter_list
(type_parameter) @type)
(type_parameter
name: (identifier) @type)
(type_parameter_constraints_clause
"where"
.
(identifier) @type)
(attribute
name: (identifier) @attribute)
(foreach_statement
type: (identifier) @type)
(goto_statement
(identifier) @label)
(labeled_statement
(identifier) @label)
(tuple_element
type: (identifier) @type)
(tuple_expression
(argument
(declaration_expression
type: (identifier) @type)))
(cast_expression
type: (identifier) @type)
(lambda_expression
type: (identifier) @type)
(as_expression
right: (identifier) @type)
(typeof_expression
(identifier) @type)
(preproc_error) @keyword.exception
[
"#define"
"#undef"
] @keyword.directive.define
[
"#if"
"#elif"
"#else"
"#endif"
"#region"
"#endregion"
"#line"
"#pragma"
"#nullable"
"#error"
(shebang_directive)
] @keyword.directive
[
(preproc_line)
(preproc_pragma)
(preproc_nullable)
] @constant.macro
(preproc_pragma
(identifier) @constant)
[
"if"
"else"
"switch"
"break"
"case"
"when"
] @keyword.conditional
(preproc_pragma
(identifier) @constant)
(preproc_if
(identifier) @constant)
(preproc_if
(identifier) @constant)
[
"while"
"for"
"do"
"continue"
"goto"
"foreach"
] @keyword.repeat
[
"try"
"catch"
"throw"
"finally"
] @keyword.exception
[
"+"
"?"
":"
"++"
"-"
"--"
"&"
"&&"
"|"
"||"
"!"
"!="
"=="
"*"
"/"
"%"
"<"
"<="
">"
">="
"="
"-="
"+="
"*="
"/="
"%="
"^"
"^="
"&="
"|="
"~"
">>"
">>>"
"<<"
"<<="
">>="
">>>="
"=>"
"??"
"??="
".."
] @operator
[
";"
"."
","
":"
] @punctuation.delimiter
(conditional_expression
[
"?"
":"
] @keyword.conditional.ternary)
[
"["
"]"
"{"
"}"
"("
")"
] @punctuation.bracket
(interpolation_brace) @punctuation.special
(type_argument_list
[
"<"
">"
] @punctuation.bracket)
[
"using"
"as"
] @keyword.import
(alias_qualified_name
(identifier
"global") @keyword.import)
[
"with"
"new"
"typeof"
"sizeof"
"is"
"and"
"or"
"not"
"stackalloc"
"__makeref"
"__reftype"
"__refvalue"
"in"
"out"
"ref"
] @keyword.operator
[
"lock"
"params"
"operator"
"default"
"implicit"
"explicit"
"override"
"get"
"set"
"init"
"where"
"add"
"remove"
"checked"
"unchecked"
"fixed"
"alias"
"file"
"unsafe"
] @keyword
(attribute_target_specifier
.
_ @keyword)
[
"enum"
"record"
"class"
"struct"
"interface"
"namespace"
"event"
"delegate"
] @keyword.type
[
"async"
"await"
] @keyword.coroutine
[
"const"
"extern"
"readonly"
"static"
"volatile"
"required"
"managed"
"unmanaged"
"notnull"
"abstract"
"private"
"protected"
"internal"
"public"
"partial"
"sealed"
"virtual"
"global"
] @keyword.modifier
(scoped_type
"scoped" @keyword.modifier)
(query_expression
(_
[
"from"
"orderby"
"select"
"group"
"by"
"ascending"
"descending"
"equals"
"let"
] @keyword))
[
"return"
"yield"
] @keyword.return

View File

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

View File

@ -0,0 +1,42 @@
; Definitions
(variable_declarator
.
(identifier) @local.definition.var)
(variable_declarator
(tuple_pattern
(identifier) @local.definition.var))
(declaration_expression
name: (identifier) @local.definition.var)
(foreach_statement
left: (identifier) @local.definition.var)
(foreach_statement
left: (tuple_pattern
(identifier) @local.definition.var))
(parameter
(identifier) @local.definition.parameter)
(method_declaration
name: (identifier) @local.definition.method)
(local_function_statement
name: (identifier) @local.definition.method)
(property_declaration
name: (identifier) @local.definition)
(type_parameter
(identifier) @local.definition.type)
(class_declaration
name: (identifier) @local.definition)
; References
(identifier) @local.reference
; Scope
(block) @local.scope

View File

@ -0,0 +1,26 @@
[
(mod_item)
(struct_item)
(trait_item)
(enum_item)
(impl_item)
(type_item)
(use_declaration)
(let_declaration)
(namespace_definition)
(arguments)
(implicit_arguments)
(tuple_type)
(import_statement)
(attribute_statement)
(with_statement)
(if_statement)
(function_definition)
(struct_definition)
(loop_expression)
(if_expression)
(match_expression)
(call_expression)
(tuple_expression)
(attribute_item)
] @fold

View File

@ -0,0 +1,414 @@
; Preproc
[
"%builtins"
"%lang"
] @keyword.directive
; Includes
(import_statement
[
"from"
"import"
] @keyword.import
module_name: (dotted_name
(identifier) @module .))
[
"as"
"use"
"mod"
] @keyword.import
; Variables
(identifier) @variable
; Namespaces
(namespace_definition
(identifier) @module)
(mod_item
name: (identifier) @module)
(use_list
(self) @module)
(scoped_use_list
(self) @module)
(scoped_identifier
path: (identifier) @module)
(scoped_identifier
(scoped_identifier
name: (identifier) @module))
(scoped_type_identifier
path: (identifier) @module)
((scoped_identifier
path: (identifier) @type)
(#lua-match? @type "^[A-Z]"))
((scoped_identifier
name: (identifier) @type)
(#lua-match? @type "^[A-Z]"))
((scoped_identifier
name: (identifier) @constant)
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
((scoped_identifier
path: (identifier) @type
name: (identifier) @constant)
(#lua-match? @type "^[A-Z]")
(#lua-match? @constant "^[A-Z]"))
((scoped_type_identifier
path: (identifier) @type
name: (type_identifier) @constant)
(#lua-match? @type "^[A-Z]")
(#lua-match? @constant "^[A-Z]"))
(scoped_use_list
path: (identifier) @module)
(scoped_use_list
path: (scoped_identifier
(identifier) @module))
(use_list
(scoped_identifier
(identifier) @module
.
(_)))
(use_list
(identifier) @type
(#lua-match? @type "^[A-Z]"))
(use_as_clause
alias: (identifier) @type
(#lua-match? @type "^[A-Z]"))
; Keywords
[
; 0.x
"using"
"let"
"const"
"local"
"rel"
"abs"
"dw"
"alloc_locals"
(inst_ret)
"with_attr"
"with"
"call"
"nondet"
; 1.0
"impl"
"implicits"
"of"
"ref"
"mut"
] @keyword
[
"struct"
"enum"
"namespace"
"type"
"trait"
] @keyword.type
[
"func"
"fn"
"end"
] @keyword.function
"return" @keyword.return
[
"cast"
"new"
"and"
] @keyword.operator
[
"tempvar"
"extern"
] @keyword.modifier
[
"if"
"else"
"match"
] @keyword.conditional
"loop" @keyword.repeat
[
"assert"
"static_assert"
"nopanic"
] @keyword.exception
; Fields
(implicit_arguments
(typed_identifier
(identifier) @variable.member))
(member_expression
"."
(identifier) @variable.member)
(call_expression
(assignment_expression
left: (identifier) @variable.member))
(tuple_expression
(assignment_expression
left: (identifier) @variable.member))
(field_identifier) @variable.member
(shorthand_field_initializer
(identifier) @variable.member)
; Parameters
(arguments
(typed_identifier
(identifier) @variable.parameter))
(call_expression
(tuple_expression
(assignment_expression
left: (identifier) @variable.parameter)))
(return_type
(tuple_type
(named_type
.
(identifier) @variable.parameter)))
(parameter
(identifier) @variable.parameter)
; Builtins
(builtin_directive
(identifier) @variable.builtin)
(lang_directive
(identifier) @variable.builtin)
[
"ap"
"fp"
(self)
] @variable.builtin
; Functions
(function_definition
"func"
(identifier) @function)
(function_definition
"fn"
(identifier) @function)
(function_signature
"fn"
(identifier) @function)
(extern_function_statement
(identifier) @function)
(call_expression
function: (identifier) @function.call)
(call_expression
function: (scoped_identifier
(identifier) @function.call .))
(call_expression
function: (field_expression
field: (field_identifier) @function.call))
"jmp" @function.builtin
; Types
(struct_definition
.
(identifier) @type
(typed_identifier
(identifier) @variable.member)?)
(named_type
(identifier) @type .)
[
(builtin_type)
(primitive_type)
] @type.builtin
((identifier) @type
(#lua-match? @type "^[A-Z][a-zA-Z0-9_]*$"))
(type_identifier) @type
; Constants
((identifier) @constant
(#lua-match? @constant "^[A-Z_][A-Z0-9_]*$"))
(enum_variant
name: (identifier) @constant)
(call_expression
function: (scoped_identifier
"::"
name: (identifier) @constant)
(#lua-match? @constant "^[A-Z]"))
((match_arm
pattern: (match_pattern
(identifier) @constant))
(#lua-match? @constant "^[A-Z]"))
((match_arm
pattern: (match_pattern
(scoped_identifier
name: (identifier) @constant)))
(#lua-match? @constant "^[A-Z]"))
((identifier) @constant.builtin
(#any-of? @constant.builtin "Some" "None" "Ok" "Err"))
; Constructors
(unary_expression
"new"
(call_expression
.
(identifier) @constructor))
((call_expression
.
(identifier) @constructor)
(#lua-match? @constructor "^%u"))
; Attributes
(decorator
"@" @attribute
(identifier) @attribute)
(attribute_item
(identifier) @function.macro)
(attribute_item
(scoped_identifier
(identifier) @function.macro .))
; Labels
(label
.
(identifier) @label)
(inst_jmp_to_label
"jmp"
.
(identifier) @label)
(inst_jnz_to_label
"jmp"
.
(identifier) @label)
; Operators
[
"+"
"-"
"*"
"/"
"**"
"=="
"!="
"&"
"="
"++"
"+="
"@"
"!"
"~"
".."
"&&"
"||"
"^"
"<"
"<="
">"
">="
"<<"
">>"
"%"
"-="
"*="
"/="
"%="
"&="
"|="
"^="
"<<="
">>="
"?"
] @operator
; Literals
(number) @number
(boolean) @boolean
[
(string)
(short_string)
] @string
; Punctuation
(attribute_item
"#" @punctuation.special)
[
"."
","
":"
";"
"->"
"=>"
"::"
] @punctuation.delimiter
[
"{"
"}"
"("
")"
"["
"]"
"%{"
"%}"
] @punctuation.bracket
(type_parameters
[
"<"
">"
] @punctuation.bracket)
(type_arguments
[
"<"
">"
] @punctuation.bracket)
; Comment
(comment) @comment @spell

View File

@ -0,0 +1,57 @@
[
(mod_item)
(struct_item)
(enum_item)
(impl_item)
(struct_expression)
(match_expression)
(tuple_expression)
(match_arm)
(match_block)
(call_expression)
(assignment_expression)
(arguments)
(block)
(use_list)
(field_declaration_list)
(enum_variant_list)
(tuple_pattern)
] @indent.begin
(import_statement
"(") @indent.begin
(block
"}" @indent.end)
(enum_item
body: (enum_variant_list
"}" @indent.end))
(match_expression
body: (match_block
"}" @indent.end))
(mod_item
body: (declaration_list
"}" @indent.end))
(struct_item
body: (field_declaration_list
"}" @indent.end))
(trait_item
body: (declaration_list
"}" @indent.end))
[
")"
"]"
"}"
] @indent.branch
[
(comment)
(string)
(short_string)
] @indent.ignore

View File

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

View File

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

View File

@ -0,0 +1,14 @@
[
(annotation_targets)
(const_list)
(enum)
(interface)
(implicit_generics)
(generics)
(group)
(method_parameters)
(named_return_types)
(struct)
(struct_shorthand)
(union)
] @fold

View File

@ -0,0 +1,141 @@
; Preproc
[
(unique_id)
(top_level_annotation_body)
] @keyword.directive
; Includes
[
"import"
"$import"
"embed"
"using"
] @keyword.import
(import_path) @string.special.path
; Keywords
"extends" @keyword
[
"struct"
"interface"
"union"
"enum"
"annotation"
"group"
"namespace"
] @keyword.type
; Builtins
"const" @keyword.modifier
[
(primitive_type)
"List"
] @type.builtin
; Typedefs
(type_definition) @type.definition
; Labels (@number, @number!)
(field_version) @label
; Methods
[
(annotation_definition_identifier)
(method_identifier)
] @function.method
; Fields
(field_identifier) @variable.member
; Properties
(property) @property
; Parameters
[
(param_identifier)
(return_identifier)
] @variable.parameter
(annotation_target) @variable.parameter.builtin
; Constants
[
(const_identifier)
(local_const)
(enum_member)
] @constant
(void) @constant.builtin
; Types
[
(enum_identifier)
(extend_type)
(type_identifier)
] @type
; Attributes
[
(annotation_identifier)
(attribute)
] @attribute
; Operators
"=" @operator
; Literals
[
(string)
(concatenated_string)
(block_text)
(namespace)
] @string
(namespace) @string.special
(escape_sequence) @string.escape
(data_string) @string.special
(number) @number
(float) @number.float
(boolean) @boolean
(data_hex) @string.special.symbol
; Punctuation
[
"*"
"$"
":"
] @punctuation.special
[
"{"
"}"
] @punctuation.bracket
[
"("
")"
] @punctuation.bracket
[
"["
"]"
] @punctuation.bracket
[
"."
","
";"
"->"
] @punctuation.delimiter
; Comments
(comment) @comment @spell

View File

@ -0,0 +1,40 @@
[
(annotation_targets)
(const)
(enum)
(interface)
(implicit_generics)
(generics)
(group)
(method_parameters)
(named_return_types)
(struct)
(union)
(field)
] @indent.begin
((struct_shorthand
(property)) @indent.align
(#set! indent.open_delimiter "(")
(#set! indent.close_delimiter ")"))
((method
(field_version)) @indent.align
(#set! indent.open_delimiter field_version))
((const_list
(const_value)) @indent.align
(#set! indent.open_delimiter "[")
(#set! indent.close_delimiter "]"))
(concatenated_string) @indent.align
[
"}"
")"
] @indent.end @indent.branch
[
(ERROR)
(comment)
] @indent.auto

View File

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

View File

@ -0,0 +1,97 @@
[
(message)
(annotation_targets)
(const_list)
(enum)
(interface)
(implicit_generics)
(generics)
(group)
(method_parameters)
(named_return_types)
(struct)
(struct_shorthand)
(union)
] @local.scope
[
(extend_type)
(field_type)
] @local.reference
(custom_type
(type_identifier) @local.reference)
(custom_type
(generics
(generic_parameters
(generic_identifier) @local.reference)))
(annotation_definition_identifier) @local.definition
(const_identifier) @local.definition.constant
(enum
(enum_identifier) @local.definition.enum)
[
(enum_member)
(field_identifier)
] @local.definition.field
(method_identifier) @local.definition.method
(namespace) @local.definition.namespace
[
(param_identifier)
(return_identifier)
] @local.definition.parameter
(group
(type_identifier) @local.definition.type)
(struct
(type_identifier) @local.definition.type)
(union
(type_identifier) @local.definition.type)
(interface
(type_identifier) @local.definition.type)
; Generics Related (don't know how to combine these)
(struct
(generics
(generic_parameters
(generic_identifier) @local.definition.parameter)))
(interface
(generics
(generic_parameters
(generic_identifier) @local.definition.parameter)))
(method
(implicit_generics
(implicit_generic_parameters
(generic_identifier) @local.definition.parameter)))
(method
(generics
(generic_parameters
(generic_identifier) @local.definition.parameter)))
(annotation
(generics
(generic_parameters
(generic_identifier) @local.definition.type)))
(replace_using
(generics
(generic_parameters
(generic_identifier) @local.definition.type)))
(return_type
(generics
(generic_parameters
(generic_identifier) @local.definition.type)))

View File

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

View File

@ -0,0 +1,54 @@
; Punctuation
[
"%["
"@["
"~["
"*["
"]"
"("
")"
] @punctuation.bracket
"," @punctuation.delimiter
(eq) @operator
([
"\""
"'"
] @punctuation.special
(#set! conceal ""))
[
"%"
"?"
"#"
] @character.special
; Entities
(intent) @module
(slot) @type
(variation) @attribute
(alias) @keyword.directive
(number) @number
(argument
key: (string) @property
value: (string) @string)
(escape) @string.escape
; Import
"import" @keyword.import
(file) @string.special.path
; Text
(word) @spell
; Comment
(comment) @comment @spell

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,347 @@
; >> Explanation
; 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
; highlighted as they should be.
;
; For the most part this means that some things have to be assigned multiple
; groups.
; By doing this we can add a basic capture and then later refine it with more
; specialized captures.
; This can mean that sometimes things are highlighted weirdly because they
; have multiple highlight groups applied to them.
; >> Literals
((dis_expr) @comment
(#set! "priority" 105)
; Higher priority to mark the whole sexpr as a comment
)
(kwd_lit) @string.special.symbol
(str_lit) @string
(num_lit) @number
(char_lit) @character
(bool_lit) @boolean
(nil_lit) @constant.builtin
(comment) @comment @spell
(regex_lit) @string.regexp
[
"'"
"`"
] @string.escape
[
"~"
"~@"
"#"
] @punctuation.special
[
"{"
"}"
"["
"]"
"("
")"
] @punctuation.bracket
; >> Symbols
; General symbol highlighting
(sym_lit) @variable
; General function calls
(list_lit
.
(sym_lit) @function.call)
(anon_fn_lit
.
(sym_lit) @function.call)
; Quoted symbols
(quoting_lit
(sym_lit) @string.special.symbol)
(syn_quoting_lit
(sym_lit) @string.special.symbol)
; Used in destructure pattern
((sym_lit) @variable.parameter
(#lua-match? @variable.parameter "^[&]"))
; Inline function variables
((sym_lit) @variable.builtin
(#lua-match? @variable.builtin "^%%%d*$"))
((sym_lit) @variable.builtin
(#eq? @variable.builtin "%&"))
; Constructor
((sym_lit) @constructor
(#lua-match? @constructor "^-%>[^>].*"))
; Builtin dynamic variables
((sym_lit) @variable.builtin
(#any-of? @variable.builtin
"*agent*" "*allow-unresolved-vars*" "*assert*" "*clojure-version*" "*command-line-args*"
"*compile-files*" "*compile-path*" "*compiler-options*" "*data-readers*"
"*default-data-reader-fn*" "*err*" "*file*" "*flush-on-newline*" "*fn-loader*" "*in*"
"*math-context*" "*ns*" "*out*" "*print-dup*" "*print-length*" "*print-level*" "*print-meta*"
"*print-namespace-maps*" "*print-readably*" "*read-eval*" "*reader-resolver*" "*source-path*"
"*suppress-read*" "*unchecked-math*" "*use-context-classloader*" "*verbose-defrecords*"
"*warn-on-reflection*"))
; Builtin repl variables
((sym_lit) @variable.builtin
(#any-of? @variable.builtin "*1" "*2" "*3" "*e"))
; Types
(sym_lit
name: (sym_name) @_name
(#lua-match? @_name "^[%u][^/%s]*$")) @type
; Symbols with `.` but not `/`
(sym_lit
!namespace
name: (sym_name) @_name
(#lua-match? @_name "^[^.]+[.]")) @type
; Interop
; (.instanceMember instance args*)
; (.instanceMember Classname args*)
((sym_lit
name: (sym_name) @_name) @function.method
(#lua-match? @_name "^%.[^-]"))
; (.-instanceField instance)
((sym_name) @variable.member
(#lua-match? @variable.member "^%.%-%S*"))
; Classname/staticField
(sym_lit
namespace: (sym_ns) @_namespace
(#lua-match? @_namespace "^[%u]%S*$")) @variable.member
; (Classname/staticMethod args*)
(list_lit
.
(sym_lit
namespace: (sym_ns) @_namespace
(#lua-match? @_namespace "^%u")) @function.method)
; TODO: Special casing for the `.` macro
; Operators
((sym_lit) @operator
(#any-of? @operator "*" "*'" "+" "+'" "-" "-'" "/" "<" "<=" ">" ">=" "=" "=="))
((sym_lit) @keyword.operator
(#any-of? @keyword.operator "not" "not=" "and" "or"))
; Definition functions
((sym_lit) @keyword
(#any-of? @keyword
"def" "defonce" "defrecord" "defmacro" "definline" "definterface" "defmulti" "defmethod"
"defstruct" "defprotocol" "deftype"))
((sym_lit) @keyword
(#eq? @keyword "declare"))
((sym_name) @keyword.coroutine
(#any-of? @keyword.coroutine
"alts!" "alts!!" "await" "await-for" "await1" "chan" "close!" "future" "go" "sync" "thread"
"timeout" "<!" "<!!" ">!" ">!!"))
((sym_lit
name: (sym_name) @_keyword.function.name) @keyword.function
(#any-of? @_keyword.function.name "defn" "defn-" "fn" "fn*"))
; Comment
((sym_lit) @comment
(#eq? @comment "comment"))
; Conditionals
((sym_lit) @keyword.conditional
(#any-of? @keyword.conditional "case" "cond" "cond->" "cond->>" "condp"))
((sym_lit) @keyword.conditional
(#any-of? @keyword.conditional "if" "if-let" "if-not" "if-some"))
((sym_lit) @keyword.conditional
(#any-of? @keyword.conditional "when" "when-first" "when-let" "when-not" "when-some"))
; Repeats
((sym_lit) @keyword.repeat
(#any-of? @keyword.repeat "doseq" "dotimes" "for" "loop" "recur" "while"))
; Exception
((sym_lit) @keyword.exception
(#any-of? @keyword.exception "throw" "try" "catch" "finally"))
; Includes
((sym_lit) @keyword.import
(#any-of? @keyword.import "ns" "import" "require" "use"))
; Builtin macros
; TODO: Do all these items belong here?
((sym_lit
name: (sym_name) @function.macro)
(#any-of? @function.macro
"." ".." "->" "->>" "amap" "areduce" "as->" "assert" "binding" "bound-fn" "delay" "do" "dosync"
"doto" "extend-protocol" "extend-type" "gen-class" "gen-interface" "io!" "lazy-cat" "lazy-seq"
"let" "letfn" "locking" "memfn" "monitor-enter" "monitor-exit" "proxy" "proxy-super" "pvalues"
"refer-clojure" "reify" "set!" "some->" "some->>" "time" "unquote" "unquote-splicing" "var"
"vswap!" "with-bindings" "with-in-str" "with-loading-context" "with-local-vars" "with-open"
"with-out-str" "with-precision" "with-redefs"))
; All builtin functions
; (->> (ns-publics *ns*)
; (keep (fn [[s v]] (when-not (:macro (meta v)) s)))
; sort
; clojure.pprint/pprint))
; ...and then lots of manual filtering...
((sym_lit
name: (sym_name) @function.builtin)
(#any-of? @function.builtin
"->ArrayChunk" "->Eduction" "->Vec" "->VecNode" "->VecSeq" "-cache-protocol-fn" "-reset-methods"
"PrintWriter-on" "StackTraceElement->vec" "Throwable->map" "accessor" "aclone" "add-classpath"
"add-tap" "add-watch" "agent" "agent-error" "agent-errors" "aget" "alength" "alias" "all-ns"
"alter" "alter-meta!" "alter-var-root" "ancestors" "any?" "apply" "array-map" "aset"
"aset-boolean" "aset-byte" "aset-char" "aset-double" "aset-float" "aset-int" "aset-long"
"aset-short" "assoc" "assoc!" "assoc-in" "associative?" "atom" "bases" "bean" "bigdec" "bigint"
"biginteger" "bit-and" "bit-and-not" "bit-clear" "bit-flip" "bit-not" "bit-or" "bit-set"
"bit-shift-left" "bit-shift-right" "bit-test" "bit-xor" "boolean" "boolean-array" "boolean?"
"booleans" "bound-fn*" "bound?" "bounded-count" "butlast" "byte" "byte-array" "bytes" "bytes?"
"cast" "cat" "char" "char-array" "char-escape-string" "char-name-string" "char?" "chars" "chunk"
"chunk-append" "chunk-buffer" "chunk-cons" "chunk-first" "chunk-next" "chunk-rest"
"chunked-seq?" "class" "class?" "clear-agent-errors" "clojure-version" "coll?" "commute" "comp"
"comparator" "compare" "compare-and-set!" "compile" "complement" "completing" "concat" "conj"
"conj!" "cons" "constantly" "construct-proxy" "contains?" "count" "counted?" "create-ns"
"create-struct" "cycle" "dec" "dec'" "decimal?" "dedupe" "default-data-readers" "delay?"
"deliver" "denominator" "deref" "derive" "descendants" "destructure" "disj" "disj!" "dissoc"
"dissoc!" "distinct" "distinct?" "doall" "dorun" "double" "double-array" "eduction" "empty"
"empty?" "ensure" "ensure-reduced" "enumeration-seq" "error-handler" "error-mode" "eval" "even?"
"every-pred" "every?" "extend" "extenders" "extends?" "false?" "ffirst" "file-seq" "filter"
"filterv" "find" "find-keyword" "find-ns" "find-protocol-impl" "find-protocol-method" "find-var"
"first" "flatten" "float" "float-array" "float?" "floats" "flush" "fn?" "fnext" "fnil" "force"
"format" "frequencies" "future-call" "future-cancel" "future-cancelled?" "future-done?"
"future?" "gensym" "get" "get-in" "get-method" "get-proxy-class" "get-thread-bindings"
"get-validator" "group-by" "halt-when" "hash" "hash-combine" "hash-map" "hash-ordered-coll"
"hash-set" "hash-unordered-coll" "ident?" "identical?" "identity" "ifn?" "in-ns" "inc" "inc'"
"indexed?" "init-proxy" "inst-ms" "inst-ms*" "inst?" "instance?" "int" "int-array" "int?"
"integer?" "interleave" "intern" "interpose" "into" "into-array" "ints" "isa?" "iterate"
"iterator-seq" "juxt" "keep" "keep-indexed" "key" "keys" "keyword" "keyword?" "last" "line-seq"
"list" "list*" "list?" "load" "load-file" "load-reader" "load-string" "loaded-libs" "long"
"long-array" "longs" "macroexpand" "macroexpand-1" "make-array" "make-hierarchy" "map"
"map-entry?" "map-indexed" "map?" "mapcat" "mapv" "max" "max-key" "memoize" "merge" "merge-with"
"meta" "method-sig" "methods" "min" "min-key" "mix-collection-hash" "mod" "munge" "name"
"namespace" "namespace-munge" "nat-int?" "neg-int?" "neg?" "newline" "next" "nfirst" "nil?"
"nnext" "not-any?" "not-empty" "not-every?" "ns-aliases" "ns-imports" "ns-interns" "ns-map"
"ns-name" "ns-publics" "ns-refers" "ns-resolve" "ns-unalias" "ns-unmap" "nth" "nthnext"
"nthrest" "num" "number?" "numerator" "object-array" "odd?" "parents" "partial" "partition"
"partition-all" "partition-by" "pcalls" "peek" "persistent!" "pmap" "pop" "pop!"
"pop-thread-bindings" "pos-int?" "pos?" "pr" "pr-str" "prefer-method" "prefers"
"primitives-classnames" "print" "print-ctor" "print-dup" "print-method" "print-simple"
"print-str" "printf" "println" "println-str" "prn" "prn-str" "promise" "proxy-call-with-super"
"proxy-mappings" "proxy-name" "push-thread-bindings" "qualified-ident?" "qualified-keyword?"
"qualified-symbol?" "quot" "rand" "rand-int" "rand-nth" "random-sample" "range" "ratio?"
"rational?" "rationalize" "re-find" "re-groups" "re-matcher" "re-matches" "re-pattern" "re-seq"
"read" "read+string" "read-line" "read-string" "reader-conditional" "reader-conditional?"
"realized?" "record?" "reduce" "reduce-kv" "reduced" "reduced?" "reductions" "ref"
"ref-history-count" "ref-max-history" "ref-min-history" "ref-set" "refer"
"release-pending-sends" "rem" "remove" "remove-all-methods" "remove-method" "remove-ns"
"remove-tap" "remove-watch" "repeat" "repeatedly" "replace" "replicate" "requiring-resolve"
"reset!" "reset-meta!" "reset-vals!" "resolve" "rest" "restart-agent" "resultset-seq" "reverse"
"reversible?" "rseq" "rsubseq" "run!" "satisfies?" "second" "select-keys" "send" "send-off"
"send-via" "seq" "seq?" "seqable?" "seque" "sequence" "sequential?" "set"
"set-agent-send-executor!" "set-agent-send-off-executor!" "set-error-handler!" "set-error-mode!"
"set-validator!" "set?" "short" "short-array" "shorts" "shuffle" "shutdown-agents"
"simple-ident?" "simple-keyword?" "simple-symbol?" "slurp" "some" "some-fn" "some?" "sort"
"sort-by" "sorted-map" "sorted-map-by" "sorted-set" "sorted-set-by" "sorted?" "special-symbol?"
"spit" "split-at" "split-with" "str" "string?" "struct" "struct-map" "subs" "subseq" "subvec"
"supers" "swap!" "swap-vals!" "symbol" "symbol?" "tagged-literal" "tagged-literal?" "take"
"take-last" "take-nth" "take-while" "tap>" "test" "the-ns" "thread-bound?" "to-array"
"to-array-2d" "trampoline" "transduce" "transient" "tree-seq" "true?" "type" "unchecked-add"
"unchecked-add-int" "unchecked-byte" "unchecked-char" "unchecked-dec" "unchecked-dec-int"
"unchecked-divide-int" "unchecked-double" "unchecked-float" "unchecked-inc" "unchecked-inc-int"
"unchecked-int" "unchecked-long" "unchecked-multiply" "unchecked-multiply-int"
"unchecked-negate" "unchecked-negate-int" "unchecked-remainder-int" "unchecked-short"
"unchecked-subtract" "unchecked-subtract-int" "underive" "unquote" "unquote-splicing"
"unreduced" "unsigned-bit-shift-right" "update" "update-in" "update-proxy" "uri?" "uuid?" "val"
"vals" "var-get" "var-set" "var?" "vary-meta" "vec" "vector" "vector-of" "vector?" "volatile!"
"volatile?" "vreset!" "with-bindings*" "with-meta" "with-redefs-fn" "xml-seq" "zero?" "zipmap"
; earlier
"drop" "drop-last" "drop-while" "double?" "doubles" "ex-data" "ex-info"
; 1.10
"ex-cause" "ex-message"
; 1.11
"NaN?" "abs" "infinite?" "iteration" "random-uuid" "parse-boolean" "parse-double" "parse-long"
"parse-uuid" "seq-to-map-for-destructuring" "update-keys" "update-vals"
; 1.12
"partitionv" "partitionv-all" "splitv-at"))
; >> Context based highlighting
; def-likes
; Correctly highlight docstrings
;(list_lit
;.
;(sym_lit) @_keyword ; Don't really want to highlight twice
;(#any-of? @_keyword
;"def" "defonce" "defrecord" "defmacro" "definline"
;"defmulti" "defmethod" "defstruct" "defprotocol"
;"deftype")
;.
;(sym_lit)
;.
; TODO: Add @comment highlight
;(str_lit)?
;.
;(_))
; Function definitions
(list_lit
.
((sym_lit
name: (sym_name) @_keyword.function.name)
(#any-of? @_keyword.function.name "defn" "defn-" "fn" "fn*"))
.
(sym_lit)? @function
.
; TODO: Add @comment highlight
(str_lit)?)
; TODO: Fix parameter highlighting
; I think there's a bug here in nvim-treesitter
; TODO: Reproduce bug and file ticket
;.
;[(vec_lit
; (sym_lit)* @variable.parameter)
; (list_lit
; (vec_lit
; (sym_lit)* @variable.parameter))])
;[((list_lit
; (vec_lit
; (sym_lit) @variable.parameter)
; (_)
; +
; ((vec_lit
; (sym_lit) @variable.parameter)
; (_)))
; Meta punctuation
; NOTE: When the above `Function definitions` query captures the
; the @function it also captures the child meta_lit
; We capture the meta_lit symbol (^) after so that the later
; highlighting overrides the former
"^" @punctuation.special
; namespaces
(list_lit
.
(sym_lit) @_include
(#eq? @_include "ns")
.
(sym_lit) @module)

View File

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

View File

@ -0,0 +1 @@
; placeholder file to get incremental selection to work

View File

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

View File

@ -0,0 +1,223 @@
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument)) @constant)
(#lua-match? @constant "^[%u@][%u%d_]+$"))
[
(quoted_argument)
(bracket_argument)
] @string
(variable_ref) @none
(variable) @variable
[
(bracket_comment)
(line_comment)
] @comment @spell
(normal_command
(identifier) @function)
[
"ENV"
"CACHE"
] @module
[
"$"
"{"
"}"
"<"
">"
] @punctuation.special
[
"("
")"
] @punctuation.bracket
[
(function)
(endfunction)
(macro)
(endmacro)
] @keyword.function
[
(if)
(elseif)
(else)
(endif)
] @keyword.conditional
[
(foreach)
(endforeach)
(while)
(endwhile)
] @keyword.repeat
(normal_command
(identifier) @keyword.repeat
(#match? @keyword.repeat "\\c^(continue|break)$"))
(normal_command
(identifier) @keyword.return
(#match? @keyword.return "\\c^return$"))
(function_command
(function)
(argument_list
.
(argument) @function
(argument)* @variable.parameter))
(macro_command
(macro)
(argument_list
.
(argument) @function.macro
(argument)* @variable.parameter))
(block_def
(block_command
(block) @function.builtin
(argument_list
(argument
(unquoted_argument) @constant))
(#any-of? @constant "SCOPE_FOR" "POLICIES" "VARIABLES" "PROPAGATE"))
(endblock_command
(endblock) @function.builtin))
;
((argument) @boolean
(#match? @boolean "\\c^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$"))
;
(if_command
(if)
(argument_list
(argument) @keyword.operator)
(#any-of? @keyword.operator
"NOT" "AND" "OR" "COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST" "EXISTS" "IS_NEWER_THAN"
"IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE" "MATCHES" "LESS" "GREATER" "EQUAL" "LESS_EQUAL"
"GREATER_EQUAL" "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL"
"VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL"))
(elseif_command
(elseif)
(argument_list
(argument) @keyword.operator)
(#any-of? @keyword.operator
"NOT" "AND" "OR" "COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST" "EXISTS" "IS_NEWER_THAN"
"IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE" "MATCHES" "LESS" "GREATER" "EQUAL" "LESS_EQUAL"
"GREATER_EQUAL" "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL"
"VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL"))
(normal_command
(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)$"))
(normal_command
(identifier) @_function
(argument_list
.
(argument) @variable)
(#match? @_function "\\c^set$"))
(normal_command
(identifier) @_function
(#match? @_function "\\c^set$")
(argument_list
.
(argument)
((argument) @_cache @keyword.modifier
.
(argument) @_type @type
(#any-of? @_cache "CACHE")
(#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL"))))
(normal_command
(identifier) @_function
(#match? @_function "\\c^unset$")
(argument_list
.
(argument)
(argument) @keyword.modifier
(#any-of? @keyword.modifier "CACHE" "PARENT_SCOPE")))
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
(argument_list
.
(argument) @constant
(#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND")
.
(argument) @variable
(argument) @variable .))
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
(argument_list
.
(argument) @constant
.
(argument) @variable
(#any-of? @constant
"APPEND" "FILTER" "INSERT" "POP_BACK" "POP_FRONT" "PREPEND" "REMOVE_ITEM" "REMOVE_AT"
"REMOVE_DUPLICATES" "REVERSE" "SORT")))
(normal_command
(identifier) @_function
(#match? @_function "\\c^list$")
(argument_list
.
(argument) @_transform @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")
(#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
(#eq? @_transform "TRANSFORM")
(#eq? @constant "OUTPUT_VARIABLE")))
(escape_sequence) @string.escape
((source_file
.
(line_comment) @keyword.directive @nospell)
(#lua-match? @keyword.directive "^#!/"))

View File

@ -0,0 +1,26 @@
[
(normal_command)
(if_condition)
(foreach_loop)
(while_loop)
(function_def)
(macro_def)
(block_def)
] @indent.begin
[
(elseif_command)
(else_command)
(endif_command)
(endforeach_command)
(endwhile_command)
(endfunction_command)
(endmacro_command)
(endblock_command)
] @indent.branch
")" @indent.branch
")" @indent.end
(argument_list) @indent.auto

View File

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

View File

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

View File

@ -0,0 +1,320 @@
(sym_lit) @variable
; A highlighting for functions/macros in th cl namespace is available in theHamsta/nvim-treesitter-commonlisp
;(list_lit . (sym_lit) @function.builtin (#cl-standard-function? @function.builtin))
;(list_lit . (sym_lit) @function.builtin (#cl-standard-macro? @function.macro))
(dis_expr) @comment
(defun_keyword) @function.macro
(defun_header
function_name: (_) @function)
(defun_header
lambda_list: (list_lit
(sym_lit) @variable.parameter))
(defun_header
keyword: (defun_keyword
"defmethod")
lambda_list: (list_lit
(list_lit
.
(sym_lit)
.
(sym_lit) @string.special.symbol)))
(defun_header
lambda_list: (list_lit
(list_lit
.
(sym_lit) @variable.parameter
.
(_))))
(defun_header
specifier: (sym_lit) @string.special.symbol)
[
":"
"::"
"."
] @punctuation.special
[
(accumulation_verb)
(for_clause_word)
"for"
"and"
"finally"
"thereis"
"always"
"when"
"if"
"unless"
"else"
"do"
"loop"
"below"
"in"
"from"
"across"
"repeat"
"being"
"into"
"with"
"as"
"while"
"until"
"return"
"initially"
] @function.macro
"=" @operator
(include_reader_macro) @string.special.symbol
[
"#C"
"#c"
] @number
[
(kwd_lit)
(self_referential_reader_macro)
] @string.special.symbol
(package_lit
package: (_) @module)
"cl" @module
(str_lit) @string
(num_lit) @number
((sym_lit) @boolean
(#any-of? @boolean "t" "T"))
(nil_lit) @constant.builtin
(comment) @comment @spell
; dynamic variables
((sym_lit) @variable.builtin
(#lua-match? @variable.builtin "^[*].+[*]$"))
; quote
"'" @string.escape
(format_specifier) @string.escape
(quoting_lit) @string.escape
; syntax quote
"`" @string.escape
"," @string.escape
",@" @string.escape
(syn_quoting_lit) @string.escape
(unquoting_lit) @none
(unquote_splicing_lit) @none
[
"("
")"
] @punctuation.bracket
(block_comment) @comment @spell
(with_clause
type: (_) @type)
(for_clause
type: (_) @type)
; defun-like things
(list_lit
.
(sym_lit) @function.macro
.
(sym_lit) @function
(#eq? @function.macro "deftest"))
; Macros and Special Operators
(list_lit
.
(sym_lit) @function.macro
; Generated via https://github.com/theHamsta/nvim-treesitter-commonlisp/blob/22fdc9fd6ed594176cc7299cc6f68dd21c94c63b/scripts/generate-symbols.lisp#L1-L21
(#any-of? @function.macro
"do*" "step" "handler-bind" "decf" "prog1" "destructuring-bind" "defconstant" "do" "lambda"
"with-standard-io-syntax" "case" "restart-bind" "ignore-errors" "with-slots" "prog2" "defclass"
"define-condition" "print-unreadable-object" "defvar" "when" "with-open-file" "prog" "incf"
"declaim" "and" "loop-finish" "multiple-value-bind" "pop" "psetf" "defmacro" "with-open-stream"
"define-modify-macro" "defsetf" "formatter" "call-method" "handler-case" "pushnew" "or"
"with-hash-table-iterator" "ecase" "cond" "defun" "remf" "ccase" "define-compiler-macro"
"dotimes" "multiple-value-list" "assert" "deftype" "with-accessors" "trace"
"with-simple-restart" "do-symbols" "nth-value" "define-symbol-macro" "psetq" "rotatef" "dolist"
"check-type" "multiple-value-setq" "push" "pprint-pop" "loop" "define-setf-expander"
"pprint-exit-if-list-exhausted" "with-condition-restarts" "defstruct" "with-input-from-string"
"with-compilation-unit" "defgeneric" "with-output-to-string" "untrace" "defparameter"
"ctypecase" "do-external-symbols" "etypecase" "do-all-symbols" "with-package-iterator" "unless"
"defmethod" "in-package" "defpackage" "return" "typecase" "shiftf" "setf" "pprint-logical-block"
"time" "restart-case" "prog*" "define-method-combination" "optimize"))
; constant
((sym_lit) @constant
(#lua-match? @constant "^[+].+[+]$"))
(var_quoting_lit
marker: "#'" @string.special.symbol
value: (_) @string.special.symbol)
[
"#"
"#p"
"#P"
] @string.special.symbol
(list_lit
.
(sym_lit) @function.builtin
; Generated via https://github.com/theHamsta/nvim-treesitter-commonlisp/blob/22fdc9fd6ed594176cc7299cc6f68dd21c94c63b/scripts/generate-symbols.lisp#L1-L21
(#any-of? @function.builtin
"apropos-list" "subst" "substitute" "pprint-linear" "file-namestring" "write-char" "do*"
"slot-exists-p" "file-author" "macro-function" "rassoc" "make-echo-stream"
"arithmetic-error-operation" "position-if-not" "list" "cdadr" "lisp-implementation-type"
"vector-push" "let" "length" "string-upcase" "adjoin" "digit-char" "step" "member-if"
"handler-bind" "lognot" "apply" "gcd" "slot-unbound" "stringp" "values-list" "stable-sort"
"decode-float" "make-list" "rplaca" "isqrt" "export" "synonym-stream-symbol" "function-keywords"
"replace" "tanh" "maphash" "code-char" "decf" "array-displacement" "string-not-lessp"
"slot-value" "remove-if" "cell-error-name" "vectorp" "cdddar" "two-way-stream-output-stream"
"parse-integer" "get-internal-real-time" "fourth" "make-string" "slot-missing" "byte-size"
"string-trim" "nstring-downcase" "cdaddr" "<" "labels" "interactive-stream-p" "fifth" "max"
"logxor" "pathname-name" "function" "realp" "eql" "logand" "short-site-name" "prog1"
"user-homedir-pathname" "list-all-packages" "exp" "cadar" "read-char-no-hang"
"package-error-package" "stream-external-format" "bit-andc2" "nsubstitute-if" "mapcar"
"complement" "load-logical-pathname-translations" "pprint-newline" "oddp" "caaar"
"destructuring-bind" "copy-alist" "acos" "go" "bit-nor" "defconstant" "fceiling" "tenth"
"nreverse" "=" "nunion" "slot-boundp" "string>" "count-if" "atom" "char=" "random-state-p"
"row-major-aref" "bit-andc1" "translate-pathname" "simple-vector-p" "coerce" "substitute-if-not"
"zerop" "invalid-method-error" "compile" "realpart" "remove-if-not" "pprint-tab"
"hash-table-rehash-threshold" "invoke-restart" "if" "count" "/=" "do" "initialize-instance"
"abs" "schar" "simple-condition-format-control" "delete-package" "subst-if" "lambda"
"hash-table-count" "array-has-fill-pointer-p" "bit" "with-standard-io-syntax" "parse-namestring"
"proclaim" "array-in-bounds-p" "multiple-value-call" "rplacd" "some" "graphic-char-p"
"read-from-string" "consp" "cadaar" "acons" "every" "make-pathname" "mask-field" "case"
"set-macro-character" "bit-and" "restart-bind" "echo-stream-input-stream" "compile-file"
"fill-pointer" "numberp" "acosh" "array-dimensions" "documentation" "minusp" "inspect"
"copy-structure" "integer-length" "ensure-generic-function" "char>=" "quote" "lognor"
"make-two-way-stream" "ignore-errors" "tailp" "with-slots" "fboundp"
"logical-pathname-translations" "equal" "float-sign" "shadow" "sleep" "numerator" "prog2" "getf"
"ldb-test" "round" "locally" "echo-stream-output-stream" "log" "get-macro-character"
"alphanumericp" "find-method" "nintersection" "defclass" "define-condition"
"print-unreadable-object" "defvar" "broadcast-stream-streams" "floatp" "subst-if-not" "integerp"
"translate-logical-pathname" "subsetp" "when" "write-string" "with-open-file" "clrhash"
"apropos" "intern" "min" "string-greaterp" "import" "nset-difference" "prog" "incf"
"both-case-p" "multiple-value-prog1" "characterp" "streamp" "digit-char-p" "random"
"string-lessp" "make-string-input-stream" "copy-symbol" "read-sequence" "logcount" "bit-not"
"boundp" "encode-universal-time" "third" "declaim" "map" "cons" "set-syntax-from-char" "and"
"cis" "symbol-plist" "loop-finish" "standard-char-p" "multiple-value-bind" "asin" "string" "pop"
"complex" "fdefinition" "psetf" "type-error-datum" "output-stream-p" "floor" "write-line" "<="
"defmacro" "rational" "hash-table-test" "with-open-stream" "read-char" "string-capitalize"
"get-properties" "y-or-n-p" "use-package" "remove" "compiler-macro-function" "read"
"package-nicknames" "remove-duplicates" "make-load-form-saving-slots" "dribble"
"define-modify-macro" "make-dispatch-macro-character" "close" "cosh" "open" "finish-output"
"string-downcase" "car" "nstring-capitalize" "software-type" "read-preserving-whitespace" "cadr"
"fround" "nsublis" "defsetf" "find-all-symbols" "char>" "no-applicable-method"
"compute-restarts" "pathname" "bit-orc2" "write-sequence" "pprint-tabular" "symbol-value"
"char-name" "get-decoded-time" "formatter" "bit-vector-p" "intersection" "pathname-type"
"clear-input" "call-method" "princ-to-string" "symbolp" "make-load-form" "nsubst"
"pprint-dispatch" "handler-case" "method-combination-error" "probe-file" "atan" "string<"
"type-error-expected-type" "pushnew" "unread-char" "print" "or" "with-hash-table-iterator"
"make-sequence" "ecase" "unwind-protect" "require" "sixth" "get-dispatch-macro-character"
"char-not-lessp" "read-byte" "tagbody" "file-error-pathname" "catch" "rationalp" "char-downcase"
"char-int" "array-rank" "cond" "last" "make-string-output-stream" "array-dimension"
"host-namestring" "input-stream-p" "decode-universal-time" "defun" "eval-when" "char-code"
"pathname-directory" "evenp" "subseq" "pprint" "ftruncate" "make-instance" "pathname-host"
"logbitp" "remf" "1+" "copy-pprint-dispatch" "char-upcase" "error" "read-line" "second"
"make-package" "directory" "special-operator-p" "open-stream-p" "rassoc-if-not" "ccase" "equalp"
"substitute-if" "*" "char/=" "cdr" "sqrt" "lcm" "logical-pathname" "eval"
"define-compiler-macro" "nsubstitute-if-not" "mapcon" "imagpart" "set-exclusive-or"
"simple-condition-format-arguments" "expt" "concatenate" "file-position" "macrolet" "keywordp"
"hash-table-rehash-size" "+" "eighth" "use-value" "char-equal" "bit-xor" "format" "byte"
"dotimes" "namestring" "char-not-equal" "multiple-value-list" "assert" "append" "notany" "typep"
"delete-file" "makunbound" "cdaar" "file-write-date" ">" "cdddr" "write-to-string" "funcall"
"member-if-not" "deftype" "readtable-case" "with-accessors" "truename" "constantp" "rassoc-if"
"caaadr" "tree-equal" "nset-exclusive-or" "nsubstitute" "make-instances-obsolete"
"package-use-list" "invoke-debugger" "provide" "count-if-not" "trace" "logandc1" "nthcdr"
"char<=" "functionp" "with-simple-restart" "set-dispatch-macro-character" "logorc2" "unexport"
"rest" "unbound-slot-instance" "make-hash-table" "hash-table-p" "reinitialize-instance" "nth"
"do-symbols" "nreconc" "macroexpand" "store-value" "float-precision" "remprop" "nth-value"
"define-symbol-macro" "update-instance-for-redefined-class" "identity" "progv" "progn"
"return-from" "readtablep" "rem" "symbol-name" "psetq" "wild-pathname-p" "char" "list*" "char<"
"plusp" "pairlis" "cddar" "pprint-indent" "union" "compiled-function-p" "rotatef" "abort"
"machine-type" "concatenated-stream-streams" "string-right-trim" "enough-namestring"
"arithmetic-error-operands" "ceiling" "dolist" "delete" "make-condition" "string-left-trim"
"integer-decode-float" "check-type" "notevery" "function-lambda-expression" "-"
"multiple-value-setq" "name-char" "push" "pprint-pop" "compile-file-pathname" "list-length"
"nstring-upcase" "eq" "find-if" "method-qualifiers" "caadr" "cddr" "string=" "let*"
"remove-method" "pathname-match-p" "find-package" "truncate" "caaddr" "get-setf-expansion"
"loop" "define-setf-expander" "caddr" "package-shadowing-symbols" "force-output"
"slot-makunbound" "string-not-greaterp" "cdadar" "cdaadr" "logandc2" "make-array"
"merge-pathnames" "sin" "1-" "machine-version" "ffloor" "packagep" "set-pprint-dispatch" "flet"
"gensym" "pprint-exit-if-list-exhausted" "cos" "get" "mapl" "delete-if"
"with-condition-restarts" "atanh" "copy-list" "fill" "char-not-greaterp" "bit-orc1" "mod"
"package-used-by-list" "warn" "add-method" "simple-string-p" "find-restart" "describe"
"pathname-version" "peek-char" "yes-or-no-p" "complexp" "aref" "not" "position-if" "string>="
"defstruct" "float-radix" "ninth" "caadar" "subtypep" "set" "butlast" "allocate-instance"
"with-input-from-string" "assoc" "write" "make-random-state" "bit-eqv" "float-digits"
"long-site-name" "with-compilation-unit" "delete-duplicates" "make-symbol" "room" "cdar"
"pprint-fill" "defgeneric" "macroexpand-1" "scale-float" "cdaaar"
"update-instance-for-different-class" "array-row-major-index" "ed" "file-string-length"
"ensure-directories-exist" "copy-readtable" "string<=" "seventh" "with-output-to-string"
"signum" "elt" "untrace" "null" "defparameter" "block" "prin1" "revappend" "gentemp" "ctypecase"
"ash" "sxhash" "listp" "do-external-symbols" "bit-ior" "etypecase" "sort" "change-class"
"find-class" "alpha-char-p" "map-into" "terpri" "do-all-symbols" "ldb" "logorc1" "search"
"fmakunbound" "load" "character" "string-not-equal" "pathnamep" "make-broadcast-stream" "arrayp"
"mapcan" "cerror" "invoke-restart-interactively" "assoc-if-not" "with-package-iterator"
"get-internal-run-time" "read-delimited-list" "unless" "lower-case-p" "restart-name" "/" "boole"
"defmethod" "float" "software-version" "vector-pop" "vector-push-extend" "caar" "ldiff" "member"
"find-symbol" "reduce" "svref" "describe-object" "logior" "string-equal" "type-of" "position"
"cddadr" "pathname-device" "get-output-stream-string" "symbol-package" "tan"
"compute-applicable-methods" "cddddr" "nsubst-if-not" "sublis" "set-difference"
"two-way-stream-input-stream" "adjustable-array-p" "machine-instance" "signal" "conjugate"
"caaaar" "endp" "lisp-implementation-version" "cddaar" "package-name" "adjust-array" "bit-nand"
"gethash" "in-package" "symbol-function" "make-concatenated-stream" "defpackage" "class-of"
"no-next-method" "logeqv" "deposit-field" "disassemble" "unuse-package" "copy-tree" "find"
"asinh" "class-name" "rename-file" "values" "print-not-readable-object" "mismatch" "cadadr"
"shadowing-import" "delete-if-not" "maplist" "listen" "return" "stream-element-type" "unintern"
"merge" "make-synonym-stream" "prin1-to-string" "nsubst-if" "byte-position" "phase"
"muffle-warning" "remhash" "continue" "load-time-value" "hash-table-size"
"upgraded-complex-part-type" "char-lessp" "sbit" "upgraded-array-element-type" "file-length"
"typecase" "cadddr" "first" "rationalize" "logtest" "find-if-not" "dpb" "mapc" "sinh"
"char-greaterp" "shiftf" "denominator" "get-universal-time" "nconc" "setf" "lognand"
"rename-package" "pprint-logical-block" "break" "symbol-macrolet" "the" "fresh-line"
"clear-output" "assoc-if" "string/=" "princ" "directory-namestring" "stream-error-stream"
"array-element-type" "setq" "copy-seq" "time" "restart-case" "prog*" "shared-initialize"
"array-total-size" "simple-bit-vector-p" "define-method-combination" "write-byte" "constantly"
"caddar" "print-object" "vector" "throw" "reverse" ">=" "upper-case-p" "nbutlast")
)
(list_lit
.
(sym_lit) @operator
(#match? @operator "^([+*-+=<>]|<=|>=|/=)$"))
((sym_lit) @string.special.symbol
(#lua-match? @string.special.symbol "^[&]"))
[
(array_dimension)
"#0A"
"#0a"
] @number
(char_lit) @character

View File

@ -0,0 +1,109 @@
(defun_header
function_name: (sym_lit) @local.definition.function
(#set! definition.function.scope "parent"))
(defun_header
lambda_list: (list_lit
(sym_lit) @local.definition.parameter))
(defun_header
keyword: (defun_keyword
"defmethod")
lambda_list: (list_lit
(list_lit
.
(sym_lit)
.
(sym_lit) @local.definition.type)))
(defun_header
lambda_list: (list_lit
(list_lit
.
(sym_lit) @local.definition.parameter
.
(_))))
(sym_lit) @local.reference
(defun) @local.scope
((list_lit
.
(sym_lit) @_defvar
.
(sym_lit) @local.definition.var)
(#match? @_defvar "^(cl:)?(defvar|defparameter)$"))
(list_lit
.
(sym_lit) @_deftest
.
(sym_lit) @local.definition.function
(#eq? @_deftest "deftest")) @local.scope
(list_lit
.
(sym_lit) @_deftest
.
(sym_lit) @local.definition.function
(#eq? @_deftest "deftest")) @local.scope
(for_clause
.
(sym_lit) @local.definition.var)
(with_clause
.
(sym_lit) @local.definition.var)
(loop_macro) @local.scope
(list_lit
.
(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
.
(sym_lit) @_let
(#match? @_let "(cl:|alexandria:)?(with-gensyms|dotimes|with-foreign-object)")
.
(list_lit
.
(sym_lit) @local.definition.var)) @local.scope
(list_lit
.
(kwd_lit) @_import_from
(#eq? @_import_from ":import-from")
.
(_)
(kwd_lit
(kwd_symbol) @local.definition.import))
(list_lit
.
(kwd_lit) @_import_from
(#eq? @_import_from ":import-from")
.
(_)
(sym_lit) @local.definition.import)
(list_lit
.
(kwd_lit) @_use
(#eq? @_use ":use")
(kwd_lit
(kwd_symbol) @local.definition.import))
(list_lit
.
(kwd_lit) @_use
(#eq? @_use ":use")
(sym_lit) @local.definition.import)

View File

@ -0,0 +1,22 @@
(metadata) @comment
(ingredient
"@" @punctuation.delimiter
(name)? @string.special.symbol
(amount
(quantity)? @number
(units)? @constant)?)
(timer
"~" @punctuation.delimiter
(name)? @string.special.symbol
(amount
(quantity)? @number
(units)? @constant)?)
(cookware
"#" @punctuation.delimiter
(name)? @string.special.symbol
(amount
(quantity)? @number
(units)? @constant)?)

View File

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

View File

@ -0,0 +1,26 @@
"let" @keyword
"in" @keyword
[
"{"
"}"
"["
"]"
] @punctuation.bracket
"." @punctuation.delimiter
(input) @constant
(comment) @comment @spell
(string) @string
(integer) @number
(float) @number.float
(boolean) @boolean
(null) @keyword

View File

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

View File

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

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