1

Update generated neovim config

This commit is contained in:
2024-08-15 14:28:54 +02:00
parent 07409c223d
commit 25cfcf2941
3809 changed files with 351157 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

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

View File

@ -0,0 +1,196 @@
;; 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"
"declare"
"delay"
"delta"
"digits"
"do"
"end"
"entry"
"exit"
"generic"
"interface"
"is"
"limited"
"null"
"of"
"others"
"out"
"pragma"
"private"
"range"
"synchronized"
"tagged"
"task"
"terminate"
"until"
"when"
] @keyword
[
"aliased"
"constant"
"renames"
] @storageclass
[
"mod"
"new"
"protected"
"record"
"subtype"
"type"
] @keyword.type
[
"with"
"use"
] @include
[
"body"
"function"
"overriding"
"procedure"
"package"
"separate"
] @keyword.function
[
"and"
"in"
"not"
"or"
"xor"
] @keyword.operator
[
"while"
"loop"
"for"
"parallel"
"reverse"
"some"
] @repeat
[
"return"
] @keyword.return
[
"case"
"if"
"else"
"then"
"elsif"
"select"
] @conditional
[
"exception"
"raise"
] @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" @include "type" @include)
(with_clause "private" @include)
(with_clause "limited" @include)
(use_clause (_) @namespace)
(with_clause (_) @namespace)
(loop_statement "end" @keyword.repeat)
(if_statement "end" @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" @exception)
(gnatprep_declarative_if_statement) @preproc
(gnatprep_if_statement) @preproc
(gnatprep_identifier) @preproc
(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)
;; Highlight errors in red. This is not very useful in practice, as text will
;; be highlighted as user types, and the error could be elsewhere in the code.
;; This also requires defining :hi @error guifg=Red for instance.
(ERROR) @error

View File

@ -0,0 +1,33 @@
;; 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) @scope
(package_declaration) @scope
(package_body) @scope
(subprogram_declaration) @scope
(subprogram_body) @scope
(block_statement) @scope
(with_clause (_) @definition.import)
(procedure_specification name: (_) @definition.function)
(function_specification name: (_) @definition.function)
(package_declaration name: (_) @definition.var)
(package_body name: (_) @definition.var)
(generic_instantiation . name: (_) @definition.var)
(component_declaration . (identifier) @definition.var)
(exception_declaration . (identifier) @definition.var)
(formal_object_declaration . (identifier) @definition.var)
(object_declaration . (identifier) @definition.var)
(parameter_specification . (identifier) @definition.var)
(full_type_declaration . (identifier) @definition.type)
(private_type_declaration . (identifier) @definition.type)
(private_extension_declaration . (identifier) @definition.type)
(incomplete_type_declaration . (identifier) @definition.type)
(protected_type_declaration . (identifier) @definition.type)
(formal_complete_type_declaration . (identifier) @definition.type)
(formal_incomplete_type_declaration . (identifier) @definition.type)
(task_type_declaration . (identifier) @definition.type)
(subtype_declaration . (identifier) @definition.type)
(identifier) @reference

View File

@ -0,0 +1,23 @@
;; Support for high-level text objects selections.
;; For instance:
;; vaf (v)isually select (a) (f)unction or subprogram
;; vif (v)isually select (i)nside a (f)unction or subprogram
;; vai (v)isually select (a) (i)f statement (or loop)
;; vii (v)isually select (i)nside an (i)f statement (or loop)
;;
;; https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/master/README.md
(subprogram_body) @function.outer
(subprogram_body (non_empty_declarative_part) @function.inner)
(subprogram_body (handled_sequence_of_statements) @function.inner)
(function_specification) @function.outer
(procedure_specification) @function.outer
(package_declaration) @function.outer
(generic_package_declaration) @function.outer
(package_body) @function.outer
(if_statement) @block.outer
(if_statement statements: (_) @block.inner)
(if_statement else_statements: (_) @block.inner)
(elsif_statement_item statements: (_) @block.inner)
(loop_statement) @block.outer
(loop_statement statements: (_) @block.inner)

View File

@ -0,0 +1,81 @@
;; Constants
(integer) @constant
;; 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
;; Imports and Module Declarations
"import" @include
(module_name) @namespace
;; Pragmas and comments
(pragma) @constant.macro
(comment) @comment
;; Keywords
[
"where"
"data"
"rewrite"
"postulate"
"public"
"private"
"tactic"
"Prop"
"quote"
"renaming"
"open"
"in"
"hiding"
"constructor"
"abstract"
"let"
"field"
"mutual"
"module"
"infix"
"infixl"
"infixr"
"record"
"forall"
"∀"
"->"
"→"
"\\"
"λ"
"..."
"…"
] @keyword
;; Brackets
[
"("
")"
"{"
"}"]
@punctuation.bracket

View File

@ -0,0 +1,301 @@
;; attempting to match concepts represented here:
;; https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide
[
"["
"]"
"{"
"}"
"?"
";"
] @punctuation
;; Methods
(method_declaration
name: (identifier) @method)
(method_declaration
type: (type_identifier) @type)
(method_invocation
name: (identifier) @method)
(argument_list
(identifier) @variable)
(super) @function.defaultLibrary
(explicit_constructor_invocation
arguments: (argument_list
(identifier) @variable ))
;; Annotations
(annotation
name: (identifier) @decorator)
"@" @operator
(annotation_key_value
(identifier) @variable)
;; Types
;; because itendifying it when declared doesn't carry to use
;; leans on the convention that "screaming snake case" is a const
((identifier) @variable.readonly
(#match? @variable.readonly "^_*[A-Z][A-Z\\d_]+$"))
(interface_declaration
name: (identifier) @interface)
(class_declaration
name: (identifier) @class)
(class_declaration
(superclass) @class)
(enum_declaration
name: (identifier) @enum)
(enum_constant
name: (identifier) @enumMember)
(interfaces
(type_list
(type_identifier) @interface ))
(local_variable_declaration
(type_identifier) @type )
( expression_statement (_ (identifier)) @variable)
(type_arguments "<" @punctuation)
(type_arguments ">" @punctuation)
; (identifier) @variable
((field_access
object: (identifier) @type)) ;; don't know what type of thing it is
(generic_type
(type_identifier) @type)
(type_arguments (type_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]"))
(field_declaration
type: (type_identifier) @type)
(formal_parameter
type: (type_identifier) @type
(identifier) @variable)
(method_declaration
(formal_parameters
(formal_parameter
name: (identifier) @parameter)))
(enhanced_for_statement
type: (type_identifier) @type
name: (identifier) @variable )
(enhanced_for_statement
value: (identifier) @variable)
(enhanced_for_statement
name: (identifier) @variable)
(object_creation_expression
type: (type_identifier) @type)
(array_creation_expression
type: (type_identifier) @type)
(array_type
element: (type_identifier) @type)
(catch_formal_parameter
(type_identifier) @type
name: (identifier) @variable)
(return_statement
(identifier) @variable)
(local_variable_declaration
(variable_declarator
name: (identifier) @variable ))
(for_statement
condition: (binary_expression
(identifier) @variable))
(for_statement
update: (update_expression
(identifier) @variable))
(constructor_declaration
name: (identifier) @class)
(dml_type) @function.defaultLibrary
(bound_apex_expression
(identifier) @variable)
(assignment_operator) @operator
(update_expression ["++" "--"] @operator)
(instanceof_expression
left: (identifier) @variable
right: (type_identifier) @type )
(cast_expression
type: (type_identifier) @type
value: (identifier) @variable)
(switch_expression
condition: (identifier) @variable)
(switch_rule
(switch_label
(identifier) @enumMember ))
(switch_label
(type_identifier) @type
(identifier) @variable )
(trigger_declaration
name: (identifier) @type
object: (identifier) @type
(trigger_event) @keyword
("," (trigger_event) @keyword)*)
(binary_expression
operator: [
">"
"<"
">="
"<="
"=="
"==="
"!="
"!=="
"&&"
"||"
"+"
"-"
"*"
"/"
"&"
"|"
"^"
"%"
"<<"
">>"
">>>"] @operator)
(binary_expression
(identifier) @variable)
(unary_expression
operator: [
"+"
"-"
"!"
"~"
]) @operator
(map_initializer "=>" @operator)
[
(boolean_type)
(void_type)
] @type.defaultLibrary
; Variables
(field_declaration (variable_declarator
(identifier) @property))
(field_declaration
(modifiers (modifier ["final" "static"])(modifier ["final" "static"]))
(variable_declarator
name: (identifier) @variable.readonly))
(this) @variable.defaultLibrary
; Literals
[
(int)
] @number
[
(string_literal)
] @string
[
(line_comment)
(block_comment)
] @comment
;; Keywords
[
"abstract"
"break"
"catch"
"class"
"continue"
"default"
"do"
"else"
"enum"
"extends"
"final"
"finally"
"for"
"get"
"global"
"if"
"implements"
"instanceof"
"interface"
"new"
"on"
"private"
"protected"
"public"
"return"
"set"
"static"
"switch"
"testMethod"
"throw"
"transient"
"try"
"trigger"
"virtual"
"when"
"while"
"with_sharing"
"without_sharing"
"inherited_sharing"
] @keyword
(assignment_expression
left: (identifier) @variable)
; (type_identifier) @type ;; not respecting precedence...
;; I don't love this but couldn't break them up right now
;; can't figure out how to let that be special without conflicting
;; in the grammar
"System.runAs" @method.defaultLibrary
(scoped_type_identifier
(type_identifier) @type)

View File

@ -0,0 +1,16 @@
; locals.scm
(method_declaration) @local.scope
(do_statement) @local.scope
(method_declaration
(formal_parameters (formal_parameter (identifier) @local.definition)))
(variable_declarator . (identifier) @local.definition)
(enum_declaration
name: (identifier) @local.definition)
(enum_constant
name: (identifier) @local.definition)
(identifier) @local.reference

View File

@ -0,0 +1,24 @@
(class_declaration
name: (identifier) @name) @definition.class
(interface_declaration
name: (identifier) @name) @definition.interface
(enum_declaration
name: (identifier) @name) @definition.enum
(method_invocation
name: (identifier) @name) @reference.call
(method_declaration
name: (identifier) @name) @definition.method
(interfaces
(type_list
(type_identifier ) @name)) @reference.implementation
(local_variable_declaration
(type_identifier) @name ) @reference.class
(object_creation_expression
type: (type_identifier) @name) @reference.class

View File

@ -0,0 +1,48 @@
((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: (identifier) @constructor.builtin
(#any-of? @constructor.builtin "SPISettings" "String"))
(declaration
(type_identifier) @type.builtin
(function_declarator
declarator: (identifier) @constructor.builtin)
(#eq? @type.builtin "SPISettings"))

View File

@ -0,0 +1,5 @@
(function_declarator
declarator: (identifier) @name) @definition.function
(call_expression
function: (identifier) @name) @reference.call

View File

@ -0,0 +1,63 @@
; 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,12 @@
(tag_name) @tag
(erroneous_end_tag_name) @tag.error
(doctype) @constant
(attribute_name) @attribute
(attribute_value) @string
(comment) @comment
[
"<"
">"
"</"
] @punctuation.bracket

View File

@ -0,0 +1,27 @@
(frontmatter
(frontmatter_js_block) @injection.content
(#set! injection.language "typescript"))
(attribute_interpolation
(attribute_js_expr) @injection.content
(#set! injection.language "typescript"))
; TODO proper queries for html_interpolation highlighting
(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,71 @@
((identifier) @function)
(block
(relation
(relation_literal) @function
(identifier) @property))
(block
(permission
(permission_literal) @variable.builtin
(identifier) @property))
(permission (identifier) @type)
(relation (identifier) @constant)
(perm_expression (identifier) @property)
[
(plus_literal)
(minus_literal)
(amp_literal)
] @punctuation
((hash_literal) @comment)
; relations
(rel_expression (identifier) @property)
((pipe_literal) @punctuation)
(relation
(rel_expression
(
(hash_literal)
.
(identifier) @constant
) @comment))
(call_expression
(selector_expression
(identifier) @constant))
(call_expression
function: (selector_expression
field: (field_identifier) @function.method))
(permission
(perm_expression
(
(stabby)
.
(identifier)
@function) @punctuation))
[
(true)
(false)
(nil)
] @constant.builtin
[
(caveat_literal)
(definition_literal)
] @keyword
((comment) @comment)

View File

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

View File

@ -0,0 +1,122 @@
; tree-sitter-awk v0.7.1
; https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries
; Order matters
(ns_qualified_name (namespace) @namespace)
(ns_qualified_name "::" @operator)
(func_def name: (_ (identifier) @function) @function)
(func_call name: (_ (identifier) @function) @function)
[
(identifier)
(field_ref)
] @variable
(field_ref (_) @variable)
(string) @string
(number) @number
(regex) @regexp
(comment) @comment
[
"function"
"func"
"print"
"printf"
"if"
"else"
"do"
"while"
"for"
"in"
"delete"
"return"
"exit"
"switch"
"case"
"default"
(break_statement)
(continue_statement)
(next_statement)
(nextfile_statement)
(getline_input)
(getline_file)
] @keyword
[
"@include"
"@load"
"@namespace"
(pattern)
] @namespace
(binary_exp [
"^"
"**"
"*"
"/"
"%"
"+"
"-"
"<"
">"
"<="
">="
"=="
"!="
"~"
"!~"
"in"
"&&"
"||"
] @operator)
(unary_exp [
"!"
"+"
"-"
] @operator)
(assignment_exp [
"="
"+="
"-="
"*="
"/="
"%="
"^="
] @operator)
(ternary_exp [
"?"
":"
] @operator)
(update_exp [
"++"
"--"
] @operator)
(redirected_io_statement [
">"
">>"
] @operator)
(piped_io_statement [
"|"
"|&"
] @operator)
[
";"
","
"("
")"
"["
"]"
"{"
"}"
] @operator

View File

@ -0,0 +1,56 @@
[
(string)
(raw_string)
(heredoc_body)
(heredoc_start)
] @string
(command_name) @function
(variable_name) @property
[
"case"
"do"
"done"
"elif"
"else"
"esac"
"export"
"fi"
"for"
"function"
"if"
"in"
"select"
"then"
"unset"
"until"
"while"
] @keyword
(comment) @comment
(function_definition name: (word) @function)
(file_descriptor) @number
[
(command_substitution)
(process_substitution)
(expansion)
]@embedded
[
"$"
"&&"
">"
">>"
"<"
"|"
] @operator
(
(command (_) @constant)
(#match? @constant "^-")
)

View File

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

View File

@ -0,0 +1,131 @@
;; Includes
((symbol) @keyword.control.import
(#match? @keyword.control.import "^(use|import|load)$"))
;; Keywords
((symbol) @keyword
(#match? @keyword "^(do|doc)$"))
; Keywords construct a symbol
(keyword) @string.special.symbol
;; Operators
; TODO: classify
((symbol) @operator (#match? @operator "^(&|\\*|\\+|-|<|<=|=|>|>=)$"))
;; Defining
((list
. (symbol) @label
. (symbol) @function
(symbol)? @parameter)
(#match? @label "^(def|defop|defn)$"))
((cons
. (symbol) @label
. (symbol) @function
(symbol)? @parameter)
(#match? @label "^(def|defop|defn)$"))
((symbol) @label
(#match? @label "^(def|defop|defn)$"))
;; Builtins
((symbol) @function.builtin
(#match? @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-cmd|with-args|with-entrypoint|with-default-args|with-entrypoint-args|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\\?|write|publish|export|only-globs|except-globs|recall-memo|store-memo|mask|list|list\\*|first|rest|length|second|third|map|map-pairs|foldr|foldl|concat|append|filter|conj|list->scope|merge|apply|id|always|vals|keys|memo|succeeds\\?|run|last|take|collect|take-all|insecure!|from|cd|wrap-cmd|docker-build|oci-load|mkfile|path-base|not)$"))
((symbol) @function.macro
(#match? @function.macro "^(op|fn|current-scope|quote|let|provide|module|or|and|->|curryfn|assert|refute|for|\\$|\\$\\$|linux|glob)$"))
;; Conditionals
((symbol) @keyword.control.conditional
(#match? @keyword.control.conditional "^(if|case|cond|when)$"))
;; Repeats
((symbol) @keyword.control.repeat
(#match? @keyword.control.repeat "^(each)$"))
;; Special forms
; (-> x y z) highlights first x as var, y z as function
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(symbol) @variable.parameter
(symbol) @function)
; (-> 42 x y) highlights 42 as regular number
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(_)
(symbol) @function)
;; Functions
(list
. (symbol) @function)
;; Variables
(list (symbol) @variable)
(cons (symbol) @variable)
(scope (symbol) @variable)
(symbind (symbol) @variable)
;; Namespaces
(symbind
(symbol) @namespace
. (keyword))
;; Punctuation
[ "(" ")" ] @punctuation.bracket
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
((symbol) @punctuation.delimiter
(#eq? @punctuation.delimiter "->"))
;; Literals
(string) @string
(escape_sequence) @constant.character.escape
(path) @string.special.path
(command) @string.special.path
(number) @constant.numeric.integer
(boolean) @constant.builtin.boolean
[
(ignore)
(null)
] @constant.builtin
[
"^"
] @character.special
;; Comments
(comment) @comment.line @spell

View File

@ -0,0 +1,131 @@
;; Includes
((symbol) @keyword.control.import
{{match "@keyword.control.import" "Import"}})
;; Keywords
((symbol) @keyword
{{match "@keyword" "Special"}})
; Keywords construct a symbol
(keyword) @string.special.symbol
;; Operators
; TODO: classify
((symbol) @operator (#match? @operator "^(&|\\*|\\+|-|<|<=|=|>|>=)$"))
;; Defining
((list
. (symbol) @label
. (symbol) @function
(symbol)? @parameter)
{{match "@label" "Def"}})
((cons
. (symbol) @label
. (symbol) @function
(symbol)? @parameter)
{{match "@label" "Def"}})
((symbol) @label
{{match "@label" "Def"}})
;; Builtins
((symbol) @function.builtin
{{match "@function.builtin" "Fn"}})
((symbol) @function.macro
{{match "@function.macro" "Op"}})
;; Conditionals
((symbol) @keyword.control.conditional
{{match "@keyword.control.conditional" "Cond"}})
;; Repeats
((symbol) @keyword.control.repeat
{{match "@keyword.control.repeat" "Repeat"}})
;; Special forms
; (-> x y z) highlights first x as var, y z as function
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(symbol) @variable.parameter
(symbol) @function)
; (-> 42 x y) highlights 42 as regular number
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(_)
(symbol) @function)
;; Functions
(list
. (symbol) @function)
;; Variables
(list (symbol) @variable)
(cons (symbol) @variable)
(scope (symbol) @variable)
(symbind (symbol) @variable)
;; Namespaces
(symbind
(symbol) @namespace
. (keyword))
;; Punctuation
[ "(" ")" ] @punctuation.bracket
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
((symbol) @punctuation.delimiter
(#eq? @punctuation.delimiter "->"))
;; Literals
(string) @string
(escape_sequence) @constant.character.escape
(path) @string.special.path
(command) @string.special.path
(number) @constant.numeric.integer
(boolean) @constant.builtin.boolean
[
(ignore)
(null)
] @constant.builtin
[
"^"
] @character.special
;; Comments
(comment) @comment.line @spell

View File

@ -0,0 +1,22 @@
[
(list)
(scope)
(cons)
] @indent
[
")"
"}"
"]"
] @indent_end
[ "(" ")" ] @branch
[ "{" "}" ] @branch
[ "[" "]" ] @branch
[
(ERROR)
(comment)
] @auto

View File

@ -0,0 +1 @@
(comment) @comment

View File

@ -0,0 +1,18 @@
; Scopes
[
(list)
(scope)
] @scope
; References
(symbol) @reference
; Definitions
((list
. (symbol) @_fnkw
. (symbol) @definition.function
(symbol)? @definition.parameter)
(#match? @_fnkw "^(def|defop|defn)$"))

View File

@ -0,0 +1,18 @@
; Scopes
[
(list)
(scope)
] @scope
; References
(symbol) @reference
; Definitions
((list
. (symbol) @_fnkw
. (symbol) @definition.function
(symbol)? @definition.parameter)
{{match "@_fnkw" "Def"}})

View File

@ -0,0 +1,131 @@
;; Variables
(list (symbol) @variable)
(cons (symbol) @variable)
(scope (symbol) @variable)
(symbind (symbol) @variable)
;; Functions
(list
. (symbol) @function)
; Keywords construct a symbol
(keyword) @constructor
;; Namespaces
(symbind
(symbol) @namespace
. (keyword))
;; Includes
((symbol) @include
(#any-of? @include "use" "import" "load"))
;; Keywords
((symbol) @keyword
(#any-of? @keyword "do" "doc"))
;; Defining
((list
. (symbol) @keyword.function
. (symbol) @function
(symbol)? @parameter)
(#any-of? @keyword.function "def" "defop" "defn"))
((cons
. (symbol) @keyword.function
. (symbol) @function
(symbol)? @parameter)
(#any-of? @keyword.function "def" "defop" "defn"))
((symbol) @keyword.function
(#any-of? @keyword.function "def" "defop" "defn"))
;; Builtins
((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-cmd" "with-args" "with-entrypoint" "with-default-args" "with-entrypoint-args" "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?" "write" "publish" "export" "only-globs" "except-globs" "recall-memo" "store-memo" "mask" "list" "list*" "first" "rest" "length" "second" "third" "map" "map-pairs" "foldr" "foldl" "concat" "append" "filter" "conj" "list->scope" "merge" "apply" "id" "always" "vals" "keys" "memo" "succeeds?" "run" "last" "take" "collect" "take-all" "insecure!" "from" "cd" "wrap-cmd" "docker-build" "oci-load" "mkfile" "path-base" "not"))
((symbol) @function.macro
(#any-of? @function.macro "op" "fn" "current-scope" "quote" "let" "provide" "module" "or" "and" "->" "curryfn" "assert" "refute" "for" "$" "$$" "linux" "glob"))
;; Conditionals
((symbol) @conditional
(#any-of? @conditional "if" "case" "cond" "when"))
;; Repeats
((symbol) @repeat
(#any-of? @repeat "each"))
;; Operators
; TODO: classify
((symbol) @operator (#any-of? @operator "&" "*" "+" "-" "<" "<=" "=" ">" ">="))
;; Special forms
; (-> 42 x y) highlights 42 as its default highlight
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(_)
(symbol) @function)
; (-> x y z) highlights first x as var, y z as function
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(symbol) @variable.parameter
(symbol) @function)
;; Punctuation
[ "(" ")" ] @punctuation.bracket
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
((symbol) @punctuation.delimiter
(#eq? @punctuation.delimiter "->"))
;; Literals
(string) @string
(escape_sequence) @string.escape
(path) @text.uri @string.special
(command) @string.special
(number) @number
(boolean) @boolean
[
(ignore)
(null)
] @constant.builtin
[
"^"
] @character.special
;; Comments
(comment) @comment @spell

View File

@ -0,0 +1,131 @@
;; Variables
(list (symbol) @variable)
(cons (symbol) @variable)
(scope (symbol) @variable)
(symbind (symbol) @variable)
;; Functions
(list
. (symbol) @function)
; Keywords construct a symbol
(keyword) @constructor
;; Namespaces
(symbind
(symbol) @namespace
. (keyword))
;; Includes
((symbol) @include
{{match "@include" "Import"}})
;; Keywords
((symbol) @keyword
{{match "@keyword" "Special"}})
;; Defining
((list
. (symbol) @keyword.function
. (symbol) @function
(symbol)? @parameter)
{{match "@keyword.function" "Def"}})
((cons
. (symbol) @keyword.function
. (symbol) @function
(symbol)? @parameter)
{{match "@keyword.function" "Def"}})
((symbol) @keyword.function
{{match "@keyword.function" "Def"}})
;; Builtins
((symbol) @function.builtin
{{match "@function.builtin" "Fn"}})
((symbol) @function.macro
{{match "@function.macro" "Op"}})
;; Conditionals
((symbol) @conditional
{{match "@conditional" "Cond"}})
;; Repeats
((symbol) @repeat
{{match "@repeat" "Repeat"}})
;; Operators
; TODO: classify
((symbol) @operator (#any-of? @operator "&" "*" "+" "-" "<" "<=" "=" ">" ">="))
;; Special forms
; (-> 42 x y) highlights 42 as its default highlight
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(_)
(symbol) @function)
; (-> x y z) highlights first x as var, y z as function
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(symbol) @variable.parameter
(symbol) @function)
;; Punctuation
[ "(" ")" ] @punctuation.bracket
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
((symbol) @punctuation.delimiter
(#eq? @punctuation.delimiter "->"))
;; Literals
(string) @string
(escape_sequence) @string.escape
(path) @text.uri @string.special
(command) @string.special
(number) @number
(boolean) @boolean
[
(ignore)
(null)
] @constant.builtin
[
"^"
] @character.special
;; Comments
(comment) @comment @spell

View File

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

View File

@ -0,0 +1,47 @@
[
(string_type)
(preamble_type)
(entry_type)
] @keyword
[
(junk)
(comment)
] @comment
[
"="
"#"
] @operator
(command) @function.builtin
(number) @number
(field
name: (identifier) @variable.builtin)
(token
(identifier) @variable.parameter)
[
(brace_word)
(quote_word)
] @string
[
(key_brace)
(key_paren)
] @attribute
(string
name: (identifier) @constant)
[
"{"
"}"
"("
")"
] @punctuation.bracket
"," @punctuation.delimiter

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,29 @@
[
(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,360 @@
; Includes
[
"inherit"
"include"
"require"
"export"
"import"
] @include
; 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" @include
"__future__" @constant.builtin)
(import_from_statement "from" @include)
"import" @include
(aliased_import "as" @include)
["if" "elif" "else"] @conditional
["for" "while" "break" "continue"] @repeat
[
"try"
"except"
"except*"
"raise"
"finally"
] @exception
(raise_statement "from" @exception)
(try_statement
(else_clause
"else" @exception))
[
"addtask"
"deltask"
"addhandler"
"def"
"lambda"
] @keyword.function
[
"before"
"after"
] @storageclass
[
"append"
"prepend"
"remove"
] @type.qualifier
; 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) @field
((attribute
attribute: (python_identifier) @field)
(#lua-match? @field "^[%l_].*$"))
; Functions
(call
function: (python_identifier) @function.call)
(call
function: (attribute
attribute: (python_identifier) @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) @namespace
;; Normal parameters
(parameters
(python_identifier) @parameter)
;; Lambda parameters
(lambda_parameters
(python_identifier) @parameter)
(lambda_parameters
(tuple_pattern
(python_identifier) @parameter))
; Default parameters
(keyword_argument
name: (python_identifier) @parameter)
; Naming parameters on call-site
(default_parameter
name: (python_identifier) @parameter)
(typed_parameter
(python_identifier) @parameter)
(typed_default_parameter
(python_identifier) @parameter)
; Variadic parameters *args, **kwargs
(parameters
(list_splat_pattern ; *args
(python_identifier) @parameter))
(parameters
(dictionary_splat_pattern ; **kwargs
(python_identifier) @parameter))
;; Literals
(none) @constant.builtin
[(true) (false)] @boolean
((python_identifier) @variable.builtin
(#eq? @variable.builtin "self"))
((python_identifier) @variable.builtin
(#eq? @variable.builtin "cls"))
(integer) @number
(float) @float
; Operators
[
"?="
"??="
":="
"=+"
".="
"=."
"-"
"-="
":="
"!="
"*"
"**"
"**="
"*="
"/"
"//"
"//="
"/="
"&"
"&="
"%"
"%="
"^"
"^="
"+"
"+="
"<"
"<<"
"<<="
"<="
"<>"
"="
"=="
">"
">="
">>"
">>="
"@"
"@="
"|"
"|="
"~"
"->"
] @operator
[
"and"
"in"
"is"
"not"
"or"
"is not"
"not in"
"del"
] @keyword.operator
; Literals
[
(string)
(python_string)
"\""
] @string
(include_path) @string.special
[
(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
(ERROR) @error

View File

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

View File

@ -0,0 +1,62 @@
(object_id) @variable
(string) @string
(escape_sequence) @string.escape
(comment) @comment
(constant) @constant.builtin
(boolean) @boolean
(using) @include
(template) @keyword
(decorator) @attribute
(property_definition (property_name) @property)
(property_definition
(property_binding
"bind" @keyword
(property_name) @property
["no-sync-create" "bidirectional" "inverted"]* @keyword))
(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)
(template_definition (template_name_qualifier) @type.qualifier)
(import_statement (gobject_library) @namespace)
(import_statement (version_number) @float)
(float) @float
(number) @number
[
";"
"."
","
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket

View File

@ -0,0 +1,8 @@
[
(list_expression)
(map_expression)
(module)
(select_expression)
] @fold
; vim: sw=2 foldmethod=marker

View File

@ -0,0 +1,68 @@
(comment) @comment
; Operators {{{
(operator) @operator
(integer_literal ("-") @operator)
; }}}
; Punctuation {{{
[
","
":"
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
; }}}
; Literal {{{
(boolean_literal) @boolean
(integer_literal) @number
[
(raw_string_literal)
(interpreted_string_literal)
] @string
(escape_sequence) @string.escape
; }}}
; Declarations {{{
(identifier) @variable
(module
type: (identifier) @function.call)
(module
(property
field: (identifier) @variable.parameter))
; }}}
; Built-ins {{{
[
(unset)
(default)
(any)
] @variable.builtin
(condition
name: (identifier) @function.builtin)
; }}}
; Expressions {{{
(map_expression
(property
field: (identifier) @property))
(select_expression
"select" @keyword.conditional)
; }}}
; vim: sw=2 foldmethod=marker

View File

@ -0,0 +1,36 @@
; Expressions {{{
(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)
; }}}
; Declarations {{{
(module) @indent.begin
(module
")" @indent.branch)
(module
"}" @indent.branch)
; }}}
; vim: sw=2 foldmethod=marker

View File

@ -0,0 +1,4 @@
((comment) @injection.content
(#set! injection.language "comment"))
; vim: sw=2 foldmethod=marker

View File

@ -0,0 +1,17 @@
(module
(property
field: (identifier) @local.definition.parameter))
(map_expression
(property
field: (identifier) @local.definition.field))
(assignment
left: (identifier) @local.definition.var)
(pattern_binding
binding: (identifier) @local.definition.var)
(identifier) @local.reference
; vim: sw=2 foldmethod=marker

View File

@ -0,0 +1,81 @@
(identifier) @variable
((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
"break" @keyword
"case" @keyword
"const" @keyword
"continue" @keyword
"default" @keyword
"do" @keyword
"else" @keyword
"enum" @keyword
"extern" @keyword
"for" @keyword
"if" @keyword
"inline" @keyword
"return" @keyword
"sizeof" @keyword
"static" @keyword
"struct" @keyword
"switch" @keyword
"typedef" @keyword
"union" @keyword
"volatile" @keyword
"while" @keyword
"#define" @keyword
"#elif" @keyword
"#else" @keyword
"#endif" @keyword
"#if" @keyword
"#ifdef" @keyword
"#ifndef" @keyword
"#include" @keyword
(preproc_directive) @keyword
"--" @operator
"-" @operator
"-=" @operator
"->" @operator
"=" @operator
"!=" @operator
"*" @operator
"&" @operator
"&&" @operator
"+" @operator
"++" @operator
"+=" @operator
"<" @operator
"==" @operator
">" @operator
"||" @operator
"." @delimiter
";" @delimiter
(string_literal) @string
(system_lib_string) @string
(null) @constant
(number_literal) @number
(char_literal) @number
(field_identifier) @property
(statement_identifier) @label
(type_identifier) @type
(primitive_type) @type
(sized_type_specifier) @type
(call_expression
function: (identifier) @function)
(call_expression
function: (field_expression
field: (field_identifier) @function))
(function_declarator
declarator: (identifier) @function)
(preproc_function_def
name: (identifier) @function.special)
(comment) @comment

View File

@ -0,0 +1,9 @@
(struct_specifier name: (type_identifier) @name body:(_)) @definition.class
(declaration type: (union_specifier name: (type_identifier) @name)) @definition.class
(function_declarator declarator: (identifier) @name) @definition.function
(type_definition declarator: (type_identifier) @name) @definition.type
(enum_specifier name: (type_identifier) @name) @definition.type

View File

@ -0,0 +1,212 @@
(identifier) @variable
;; Methods
(method_declaration name: (identifier) @function)
(local_function_statement name: (identifier) @function)
;; Types
(interface_declaration name: (identifier) @type)
(class_declaration name: (identifier) @type)
(enum_declaration name: (identifier) @type)
(struct_declaration (identifier) @type)
(record_declaration (identifier) @type)
(namespace_declaration name: (identifier) @module)
(generic_name (identifier) @type)
(type_parameter (identifier) @property.definition)
(parameter type: (identifier) @type)
(type_argument_list (identifier) @type)
(as_expression right: (identifier) @type)
(is_expression right: (identifier) @type)
(constructor_declaration name: (identifier) @constructor)
(destructor_declaration name: (identifier) @constructor)
(_ type: (identifier) @type)
(base_list (identifier) @type)
(predefined_type) @type.builtin
;; Enum
(enum_member_declaration (identifier) @property.definition)
;; Literals
[
(real_literal)
(integer_literal)
] @number
[
(character_literal)
(string_literal)
(raw_string_literal)
(verbatim_string_literal)
(interpolated_string_expression)
(interpolation_start)
(interpolation_quote)
] @string
(escape_sequence) @string.escape
[
(boolean_literal)
(null_literal)
] @constant.builtin
;; Comments
(comment) @comment
;; Tokens
[
";"
"."
","
] @punctuation.delimiter
[
"--"
"-"
"-="
"&"
"&="
"&&"
"+"
"++"
"+="
"<"
"<="
"<<"
"<<="
"="
"=="
"!"
"!="
"=>"
">"
">="
">>"
">>="
">>>"
">>>="
"|"
"|="
"||"
"?"
"??"
"??="
"^"
"^="
"~"
"*"
"*="
"/"
"/="
"%"
"%="
":"
] @operator
[
"("
")"
"["
"]"
"{"
"}"
(interpolation_brace)
] @punctuation.bracket
;; Keywords
[
(modifier)
"this"
(implicit_type)
] @keyword
[
"add"
"alias"
"as"
"base"
"break"
"case"
"catch"
"checked"
"class"
"continue"
"default"
"delegate"
"do"
"else"
"enum"
"event"
"explicit"
"extern"
"finally"
"for"
"foreach"
"global"
"goto"
"if"
"implicit"
"interface"
"is"
"lock"
"namespace"
"notnull"
"operator"
"params"
"return"
"remove"
"sizeof"
"stackalloc"
"static"
"struct"
"switch"
"throw"
"try"
"typeof"
"unchecked"
"using"
"while"
"new"
"await"
"in"
"yield"
"get"
"set"
"when"
"out"
"ref"
"from"
"where"
"select"
"record"
"init"
"with"
"let"
] @keyword
;; Attribute
(attribute name: (identifier) @attribute)
;; Parameters
(parameter
name: (identifier) @variable.parameter)
;; Type constraints
(type_parameter_constraints_clause (identifier) @property.definition)
;; Method calls
(invocation_expression (member_access_expression name: (identifier) @function))

View File

@ -0,0 +1,23 @@
(class_declaration name: (identifier) @name) @definition.class
(class_declaration (base_list (_) @name)) @reference.class
(interface_declaration name: (identifier) @name) @definition.interface
(interface_declaration (base_list (_) @name)) @reference.interface
(method_declaration name: (identifier) @name) @definition.method
(object_creation_expression type: (identifier) @name) @reference.class
(type_parameter_constraints_clause (identifier) @name) @reference.class
(type_parameter_constraint (type type: (identifier) @name)) @reference.class
(variable_declaration type: (identifier) @name) @reference.class
(invocation_expression function: (member_access_expression name: (identifier) @name)) @reference.send
(namespace_declaration name: (identifier) @name) @definition.module
(namespace_declaration name: (identifier) @name) @module

View File

@ -0,0 +1,31 @@
[
(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,338 @@
; Preproc
[
"%builtins"
"%lang"
] @preproc
; Includes
(import_statement [ "from" "import" ] @include module_name: (dotted_name (identifier) @namespace . ))
[
"as"
"use"
"mod"
] @include
; Variables
(identifier) @variable
; Namespaces
(namespace_definition (identifier) @namespace)
(mod_item
name: (identifier) @namespace)
(use_list (self) @namespace)
(scoped_use_list (self) @namespace)
(scoped_identifier
path: (identifier) @namespace)
(scoped_identifier
(scoped_identifier
name: (identifier) @namespace))
(scoped_type_identifier
path: (identifier) @namespace)
((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) @namespace)
(scoped_use_list
path: (scoped_identifier
(identifier) @namespace))
(use_list (scoped_identifier (identifier) @namespace . (_)))
(use_list (identifier) @type (#lua-match? @type "^[A-Z]"))
(use_as_clause alias: (identifier) @type (#lua-match? @type "^[A-Z]"))
; Keywords
[
; 0.x
"using"
"namespace"
"struct"
"let"
"const"
"local"
"rel"
"abs"
"dw"
"alloc_locals"
(inst_ret)
"with_attr"
"with"
"call"
"nondet"
; 1.0
"type"
"impl"
"implicits"
"of"
"ref"
"mut"
"trait"
"enum"
] @keyword
[
"func"
"fn"
"end"
] @keyword.function
"return" @keyword.return
[
"cast"
"new"
"and"
] @keyword.operator
[
"tempvar"
"extern"
] @storageclass
[
"if"
"else"
"match"
] @conditional
[
"loop"
] @repeat
[
"assert"
"static_assert"
"nopanic"
] @exception
; Fields
(implicit_arguments (typed_identifier (identifier) @field))
(member_expression "." (identifier) @field)
(call_expression (assignment_expression left: (identifier) @field))
(tuple_expression (assignment_expression left: (identifier) @field))
(field_identifier) @field
(shorthand_field_initializer (identifier) @field)
; Parameters
(arguments (typed_identifier (identifier) @parameter))
(call_expression (tuple_expression (assignment_expression left: (identifier) @parameter)))
(return_type (tuple_type (named_type . (identifier) @parameter)))
(parameter (identifier) @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) @field)?)
(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
; Errors
(ERROR) @error

View File

@ -0,0 +1,45 @@
[
(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,3 @@
(python_code) @python
(comment) @comment

View File

@ -0,0 +1,68 @@
; References
(identifier) @reference
((type_identifier) @reference
(#set! reference.kind "type"))
((field_identifier) @reference
(#set! reference.kind "field"))
; Scopes
[
(program)
(block)
(function_definition)
(loop_expression)
(if_expression)
(match_expression)
(match_arm)
(struct_item)
(enum_item)
(impl_item)
] @scope
(use_declaration
argument: (scoped_identifier
name: (identifier) @definition.import))
(use_as_clause
alias: (identifier) @definition.import)
(use_list
(identifier) @definition.import) ; use std::process::{Child, Command, Stdio};
; Functions
(function_definition
(identifier) @definition.function)
(function_definition
(identifier) @definition.method
(parameter (self)))
; Function with parameters, defines parameters
(parameter
[ (identifier) (self) ] @definition.parameter)
; Types
(struct_item
name: (type_identifier) @definition.type)
(constrained_type_parameter
left: (type_identifier) @definition.type) ; the P in remove_file<P: AsRef<Path>>(path: P)
(enum_item
name: (type_identifier) @definition.type)
; Module
(mod_item
name: (identifier) @definition.namespace)
; Variables
(assignment_expression
left: (identifier) @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,153 @@
; Preproc
[
(unique_id)
(top_level_annotation_body)
] @preproc
; Includes
[
"import"
"$import"
"embed"
"using"
] @include
(import_path) @string @text.uri
; Keywords
[
"annotation"
"enum"
"group"
"interface"
"struct"
"union"
"extends"
"namespace"
] @keyword
; Builtins
[
"const"
] @type.qualifier
[
(primitive_type)
"List"
] @type.builtin
; Typedefs
(type_definition) @type.definition
; Labels (@number, @number!)
(field_version) @label
; Methods
[
(annotation_definition_identifier)
(method_identifier)
] @method
; Fields
(field_identifier) @field
; Properties
(property) @property
; Parameters
[
(param_identifier)
(return_identifier)
] @parameter
(annotation_target) @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) @text.underline
(escape_sequence) @string.escape
(data_string) @string.special
(number) @number
(float) @float
(boolean) @boolean
(data_hex) @symbol
; Punctuation
[
"*"
"$"
":"
] @punctuation.special
["{" "}"] @punctuation.bracket
["(" ")"] @punctuation.bracket
["[" "]"] @punctuation.bracket
[
","
";"
"->"
] @punctuation.delimiter
; Comments
(comment) @comment @spell
; Errors
(ERROR) @error

View File

@ -0,0 +1,34 @@
[
(annotation_targets)
(const_list)
(enum)
(interface)
(implicit_generics)
(generics)
(group)
(method_parameters)
(named_return_types)
(struct)
(struct_shorthand)
(union)
] @indent
((struct_shorthand (property)) @aligned_indent
(#set! "delimiter" "()"))
((const_list (const_value)) @aligned_indent
(#set! "delimiter" "[]"))
[
"}"
")"
] @indent_end
[ "{" "}" ] @branch
[ "(" ")" ] @branch
[
(ERROR)
(comment)
] @auto

View File

@ -0,0 +1 @@
(comment) @comment

View File

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

View File

@ -0,0 +1,49 @@
; Punctuation
[
"%["
"@["
"~["
"*["
"]"
"("
")"
] @punctuation.bracket
[
(eq)
","
] @punctuation.delimiter
[
"%"
"?"
"#"
] @punctuation.special
; Entities
(intent) @module
(slot) @type
(variation) @variable.member
(alias) @embedded
(number) @number
(argument
key: (string) @attribute
value: (string) @string)
(escape) @string.escape
; Import
"import" @keyword
(file) @string.special
; Text
(word) @markup
; Comment
(comment) @comment

View File

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

View File

@ -0,0 +1,29 @@
;; Literals
(num_lit) @number
[
(char_lit)
(str_lit)
] @string
[
(bool_lit)
(nil_lit)
] @constant.builtin
(kwd_lit) @constant
;; Comments
(comment) @comment
;; Treat quasiquotation as operators for the purpose of highlighting.
[
"'"
"`"
"~"
"@"
"~@"
] @operator

View File

@ -0,0 +1,122 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Function Definitions ;;;;;;;;;;;;;;;;;;;;;;;
(defun_header
function_name: (sym_lit) @name) @definition.function
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Function Calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Basically, we consider every list literal with symbol as the
;;; first element to be a call to a function named by that element.
;;; But we must exclude some cases. Note, tree-sitter @ignore
;;; cases only work if they are declared before the cases
;;; we want to include.
;; Exclude lambda lists for function definitions
;; For example:
;;
;; (defun my-func (arg1 arg2) ...)
;;
;; do not treat (arg1 arg2) as a call of function arg1
;;
(defun_header
lambda_list: (list_lit . [(sym_lit) (package_lit)] @ignore))
;; Similar to the above, but for
;;
;; (defmethod m ((type1 param1) (type2 param2)) ...)
;;
;; where list literals having symbol as their first element
;; are nested inside the lambda list.
(defun_header
lambda_list: (list_lit (list_lit . [(sym_lit) (package_lit)] @ignore)))
;;
;; (let ((var ...) (var2 ...)) ...)
;;
;; - exclude var, var2
;; - the same for let*, flet, labels, macrolet, symbol-macrolet
(list_lit . [(sym_lit) (package_lit)] @name
. (list_lit (list_lit . [(sym_lit) (package_lit)] @ignore))
(#match? @name
"(?i)^(cl:)?(let|let\\*|flet|labels|macrolet|symbol-macrolet)$")
)
;; TODO:
;; - exclude also:
;; - (defclass name (parent parent2)
;; ((slot1 ...)
;; (slot2 ...))
;; exclude the parent, slot1, slot2
;; - (flet ((func-1 (param1 param2))) ...)
;; - we already exclude func-1, but param1 is still recognized
;; as a function call - exclude it too
;; - the same for labels
;; - the same macrolet
;; - what else?
;; (that's a non-goal to completely support all macros
;; and special operators, but every one we support
;; makes the solution a little bit better)
;; - (flet ((func-1 (param1 param2))) ...)
;; - instead of simply excluding it, as we do today,
;; tag func-1 as @local.definition.function (I suppose)
;; - the same for labels, macrolet
;; - @local.scope for let, let*, flet, labels, macrolet
;; - I guess the whole span of the scope text,
;; till the closing paren, should be tagged as @local.scope;
;; Hopefully, combined with @local.definition.function
;; withing the scope, the usual @reference.call within
;; that scope will refer to the local definition,
;; and there will be no need to use @local.reference.call
;; (which is more difficult to implement).
;; - When implementing, remeber the scope rules differences
;; of let vs let*, flet vs labels.
;; Inlclude all other cases - list literal with symbol as the
;; first element
(list_lit . [(sym_lit) (package_lit)] @name) @reference.call
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; classes
(list_lit . [(sym_lit) (package_lit)] @ignore
. [(sym_lit) (package_lit)] @name
(#match? @ignore "(?i)^(cl:)?defclass$")
) @definition.class
(list_lit . [(sym_lit) (package_lit)] @ignore
. (quoting_lit [(sym_lit) (package_lit)] @name)
(#match? @ignore "(?i)^(cl:)?make-instance$")
) @reference.class
;;; TODO:
;; - @reference.class for base classes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; TODO:
;; - Symbols referenced in defpackage
;;
;; (defpackage ...
;; (:export (symbol-a :symbol-b #:symbol-c "SYMBOL-D")))
;;
;; The goal is to allow quick navigation from the API
;; overview in the form of defpackage, to the definition
;; where user can read parameters, docstring, ect.
;; - The @name must not include the colon, or sharpsign colon, quotes,
;; just symbol-a, symbol-b, symbol-c, sybmol-d
;; - Downcase the names specified as stirng literals?
;; ("SYMBOL-D" -> symbol-d)
;; - We don't know if the exported symbol is a function, variable,
;; class or something else. The oficial doc
;; (https://tree-sitter.github.io/tree-sitter/code-navigation-systems)
;; does not even suggest a tag for variable reference.
;; (Although in practice, the `tree-sitter tags` command
;; allows any @reference.* and @definition.* tags)
;; Probably it's better to just use @reference.call for all
;; the symbols in the :export clause.
;;
;; - The same for the export function call:
;;
;; (export '(symbol-a :symbol-b #:symbol-c "SYMBOL-D"))

View File

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

View File

@ -0,0 +1,24 @@
"let" @keyword
"in" @keyword
[
"{"
"}"
"["
"]"
] @punctuation.bracket
(path_seg) @string.special.key
"." @punctuation.delimiter
(input) @constant
(comment) @comment
(string) @string
(char) @string
(integer) @number
(float) @float
(boolean) @boolean
(null) @keyword
(ERROR) @error

View File

@ -0,0 +1,14 @@
[
(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,16 @@
; scopes
[
(object)
(array)
] @scope
; definitions
(assign_block
(assignment
(input)
@definition.constant))
(value (input) @reference)

View File

@ -0,0 +1,5 @@
[
(meta_map)
(map)
(array)
] @fold

View File

@ -0,0 +1,50 @@
; Literals
(string) @string
(escape_sequence) @string.escape
(hex_blob
"x" @character.special
(_) @string)
(esc_blob
"b" @character.special
(_) @string)
(datetime
"d" @character.special
(_) @string.special)
(_ key: (_) @label)
(number) @number
(float) @float
(boolean) @boolean
(null) @constant.builtin
; Punctuation
[
","
":"
] @punctuation.delimiter
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
[ "<" ">" ] @punctuation.bracket
(("\"" @conceal)
(#set! conceal ""))
; Comments
(comment) @comment @spell
; Errors
(ERROR) @error

View File

@ -0,0 +1,17 @@
[
(meta_map)
(map)
(imap)
(array)
] @indent.begin
[
"]"
"}"
">"
] @indent.end @indent.branch
[
(ERROR)
(comment)
] @indent.auto

View File

@ -0,0 +1 @@
(comment) @comment

View File

@ -0,0 +1,7 @@
[
(document)
(meta_map)
(map)
(array)
] @scope

View File

@ -0,0 +1,70 @@
; Functions
(call_expression
function: (qualified_identifier
name: (identifier) @function))
(template_function
name: (identifier) @function)
(template_method
name: (field_identifier) @function)
(template_function
name: (identifier) @function)
(function_declarator
declarator: (qualified_identifier
name: (identifier) @function))
(function_declarator
declarator: (field_identifier) @function)
; Types
((namespace_identifier) @type
(#match? @type "^[A-Z]"))
(auto) @type
; Constants
(this) @variable.builtin
(null "nullptr" @constant)
; Keywords
[
"catch"
"class"
"co_await"
"co_return"
"co_yield"
"constexpr"
"constinit"
"consteval"
"delete"
"explicit"
"final"
"friend"
"mutable"
"namespace"
"noexcept"
"new"
"override"
"private"
"protected"
"public"
"template"
"throw"
"try"
"typename"
"using"
"concept"
"requires"
(virtual)
] @keyword
; Strings
(raw_string_literal) @string

View File

@ -0,0 +1,3 @@
(raw_string_literal
delimiter: (raw_string_delimiter) @injection.language
(raw_string_content) @injection.content)

View File

@ -0,0 +1,15 @@
(struct_specifier name: (type_identifier) @name body:(_)) @definition.class
(declaration type: (union_specifier name: (type_identifier) @name)) @definition.class
(function_declarator declarator: (identifier) @name) @definition.function
(function_declarator declarator: (field_identifier) @name) @definition.function
(function_declarator declarator: (qualified_identifier scope: (namespace_identifier) @local.scope name: (identifier) @name)) @definition.method
(type_definition declarator: (type_identifier) @name) @definition.type
(enum_specifier name: (type_identifier) @name) @definition.type
(class_specifier name: (type_identifier) @name) @definition.class

View File

@ -0,0 +1,64 @@
(comment) @comment
(tag_name) @tag
(nesting_selector) @tag
(universal_selector) @tag
"~" @operator
">" @operator
"+" @operator
"-" @operator
"*" @operator
"/" @operator
"=" @operator
"^=" @operator
"|=" @operator
"~=" @operator
"$=" @operator
"*=" @operator
"and" @operator
"or" @operator
"not" @operator
"only" @operator
(attribute_selector (plain_value) @string)
(pseudo_element_selector (tag_name) @attribute)
(pseudo_class_selector (class_name) @attribute)
(class_name) @property
(id_name) @property
(namespace_name) @property
(property_name) @property
(feature_name) @property
(attribute_name) @attribute
(function_name) @function
((property_name) @variable
(#match? @variable "^--"))
((plain_value) @variable
(#match? @variable "^--"))
"@media" @keyword
"@import" @keyword
"@charset" @keyword
"@namespace" @keyword
"@supports" @keyword
"@keyframes" @keyword
(at_keyword) @keyword
(to) @keyword
(from) @keyword
(important) @keyword
(string_value) @string
(color_value) @string.special
(integer_value) @number
(float_value) @number
(unit) @type
"#" @punctuation.delimiter
"," @punctuation.delimiter
":" @punctuation.delimiter

View File

@ -0,0 +1,5 @@
(text) @string
(number) @number
(float) @float
(boolean) @boolean
"," @punctuation.delimiter

View File

@ -0,0 +1,5 @@
[
(import_spec_list)
(field)
(string)
] @fold

View File

@ -0,0 +1,165 @@
; Includes
[
"package"
"import"
] @include
; Namespaces
(package_identifier) @namespace
(import_spec ["." "_"] @punctuation.special)
[
(attr_path)
(package_path)
] @text.uri ;; In attributes
; Attributes
(attribute) @attribute
; Conditionals
"if" @conditional
; Repeats
[
"for"
] @repeat
(for_clause "_" @punctuation.special)
; Keywords
[
"let"
] @keyword
[
"in"
] @keyword.operator
; Operators
[
"+"
"-"
"*"
"/"
"|"
"&"
"||"
"&&"
"=="
"!="
"<"
"<="
">"
">="
"=~"
"!~"
"!"
"="
] @operator
; Fields & Properties
(field
(label
(identifier) @field))
(selector_expression
(_)
(identifier) @property)
; Functions
(call_expression
function: (identifier) @function.call)
(call_expression
function: (selector_expression
(_)
(identifier) @function.call))
(call_expression
function: (builtin_function) @function.call)
(builtin_function) @function.builtin
; Variables
(identifier) @variable
; Types
(primitive_type) @type.builtin
((identifier) @type
(#match? @type "^(#|_#)"))
[
(slice_type)
(pointer_type)
] @type ;; In attributes
; Punctuation
[
","
":"
] @punctuation.delimiter
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket
[ "<" ">" ] @punctuation.bracket
[
(ellipsis)
"?"
"!"
] @punctuation.special
; Literals
(string) @string
[
(escape_char)
(escape_unicode)
] @string.escape
(number) @number
(float) @float
(si_unit
(float)
(_) @symbol)
(boolean) @boolean
[
(null)
(top)
(bottom)
] @constant.builtin
; Interpolations
(interpolation "\\(" @punctuation.special (_) ")" @punctuation.special) @none
(interpolation "\\(" (identifier) @variable ")")
; Comments
(comment) @comment @spell
; Errors
(ERROR) @error

View File

@ -0,0 +1,21 @@
[
(import_spec_list)
(field)
] @indent.begin
[
"}"
"]"
")"
] @indent.end
[ "{" "}" ] @indent.branch
[ "[" "]" ] @indent.branch
[ "(" ")" ] @indent.branch
[
(ERROR)
(comment)
] @indent.auto

View File

@ -0,0 +1 @@
(comment) @comment

View File

@ -0,0 +1,34 @@
; Scopes
[
(source_file)
(field)
(for_clause)
] @scope
; References
(identifier) @reference
; Definitions
(import_spec
path: (string) @definition.import)
(field
(label
(identifier) @definition.field))
(package_identifier) @definition.namespace
(for_clause
(identifier) @definition.variable
(expression))
(for_clause
(identifier)
(identifier) @definition.variable
(expression))
(let_clause
(identifier) @definition.variable)

View File

@ -0,0 +1,241 @@
; highlights.scm
;
; Highlighting queries for D code for use by Tree-Sitter.
;
; Copyright 2023 Garrett D'Amore
;
; Distributed under the MIT License.
; (See accompanying file LICENSE.txt or https://opensource.org/licenses/MIT)
; SPDX-License-Identifier: MIT
; these are listed first, because they override keyword queries
(identity_expression (in) @operator)
(identity_expression (is) @operator)
(storage_class) @keyword.storage
(function_declaration (identifier) @function)
(call_expression (identifier) @function)
(call_expression (type (identifier) @function))
(module_fqn) @namespace
[
(abstract)
(alias)
(align)
(asm)
(assert)
(auto)
(cast)
(const)
(debug)
(delete)
(deprecated)
(export)
(extern)
(final)
(immutable)
(in)
(inout)
(invariant)
(is)
(lazy)
; "macro" - obsolete
(mixin)
(module)
(new)
(nothrow)
(out)
(override)
(package)
(pragma)
(private)
(protected)
(public)
(pure)
(ref)
(scope)
(shared)
(static)
(super)
(synchronized)
(template)
(this)
(throw)
(typeid)
(typeof)
(unittest)
(version)
(with)
(gshared)
(traits)
(vector)
(parameters_)
] @keyword
[
(class)
(struct)
(interface)
(union)
(enum)
(function)
(delegate)
] @keyword.storage.type
[
(break)
(case)
(catch)
(continue)
(do)
(default)
(finally)
(else)
(goto)
(if)
(switch)
(try)
] @keyword.control
(return) @keyword.control.return
(import) @keyword.control.import
[
(for)
(foreach)
(foreach_reverse)
(while)
] @keyword.control.repeat
[
(not_in)
(not_is)
"/="
"/"
".."
"..."
"&"
"&="
"&&"
"|"
"|="
"||"
"-"
"-="
"--"
"+"
"+="
"++"
"<"
"<="
"<<"
"<<="
">"
">="
">>="
">>>="
">>"
">>>"
"!"
"!="
"?"
"$"
"="
"=="
"*"
"*="
"%"
"%="
"^"
"^="
"^^"
"^^="
"~"
"~="
"@"
"=>"
] @operator
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
[
";"
"."
":"
","
] @punctuation.delimiter
[
(true)
(false)
] @constant.builtin.boolean
(null) @constant.builtin
(special_keyword) @constant.builtin
(directive) @keyword.directive
(shebang) @keyword.directive
(comment) @comment
[
(void)
(bool)
(byte)
(ubyte)
(char)
(short)
(ushort)
(wchar)
(dchar)
(int)
(uint)
(long)
(ulong)
(real)
(double)
(float)
(size_t)
(ptrdiff_t)
(string)
(cstring)
(dstring)
(wstring)
(noreturn)
] @type.builtin
[
(cent)
(ucent)
(ireal)
(idouble)
(ifloat)
(creal)
(double)
(cfloat)
] @warning ; these types are deprecated
(label (identifier) @label)
(goto_statement (goto) @keyword (identifier) @label)
(string_literal) @string
(int_literal) @constant.numeric.integer
(float_literal) @constant.numeric.float
(char_literal) @constant.character
(identifier) @variable
(at_attribute) @attribute
; everything after __EOF_ is plain text
(end_file) @ui.text

View File

@ -0,0 +1,17 @@
[
(parameters)
(template_parameters)
(expression_statement)
(aggregate_body)
(function_body)
(scope_statement)
(block_statement)
(case_statement)
] @indent
[
(case)
(default)
"}"
"]"
] @outdent

View File

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

View File

@ -0,0 +1,9 @@
(function_declaration (function_body) @function.inside) @function.around
(comment) @comment.inside
(comment)+ @comment.around
(class_declaration (aggregate_body) @class.inside) @class.around
(interface_declaration (aggregate_body) @class.inside) @class.around
(struct_declaration (aggregate_body) @class.inside) @class.around
(unittest_declaration (block_statement) @test.insid) @test.around
(parameter) @parameter.inside
(template_parameter) @parameter.inside

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