add tree-sitter syntax highlighting via dart:ffi
Vendor libtree-sitter.so (v0.26.8, wasmtime 44.0 statically linked) and call its C API through dart:ffi. Grammar WASM files are loaded by tree-sitter's embedded wasmtime engine via ts_wasm_store_load_language. 48 grammars compiled with tree-sitter build --wasm, 48 highlight queries (42 from upstream repos, 6 written in-house for comment, erlang, gdscript, gitignore, hcl, hlsl, swift). SQLite grammar replaces full SQL (974K-line parser exhausted RAM at compile time). Removes wasm_run and wasm_run_flutter — they downloaded a 22 MB binary from GitHub at first launch, violating the no-network-on- default-launch-path policy. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,26 @@ heading, and (b) bumping `project.yaml` `version:` in the same commit.
|
||||
|
||||
### Added
|
||||
|
||||
- Syntax highlighting via tree-sitter (dart:ffi to vendored
|
||||
libtree-sitter.so with embedded wasmtime). 48 grammar WASM files,
|
||||
48 highlight queries. Colors map to theme syntax tokens.
|
||||
|
||||
### Changed
|
||||
|
||||
- Core frame vs shipped extension boundary defined (D-046). Builtins
|
||||
are frame infrastructure only; content extensions are bundled but
|
||||
architecturally removable.
|
||||
|
||||
### Removed
|
||||
|
||||
- `builtin.jira` stub — Jira integration belongs as a third-party
|
||||
extension, not a frame builtin.
|
||||
- `wasm_run` and `wasm_run_flutter` dependencies — replaced by
|
||||
vendored libtree-sitter.so via dart:ffi. Eliminates runtime network
|
||||
download that violated POLICY.md.
|
||||
|
||||
### Added
|
||||
|
||||
- pql skill installed via `pql init --with-skill=yes`
|
||||
(`.claude/skills/pql/SKILL.md`). Covers vault queries and the
|
||||
planning surface (decisions + tickets).
|
||||
|
||||
@@ -46,7 +46,7 @@ ifeq ($(APP_PRESENT),yes)
|
||||
@bin/clide --daemon & echo $$! > $(DAEMON_PID_FILE)
|
||||
@echo "Daemon PID $$(cat $(DAEMON_PID_FILE))"
|
||||
@echo "Launching Flutter app…"
|
||||
-cd app && flutter run -d linux
|
||||
-cd app && LD_LIBRARY_PATH=$(CURDIR)/app/native/linux-x64$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH} flutter run -d linux
|
||||
@$(MAKE) --no-print-directory stop
|
||||
else
|
||||
@echo "(pubspec.yaml not scaffolded yet; skipping)"
|
||||
|
||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -97,6 +97,38 @@ dependencies:
|
||||
the core PTY wrapper for libc bindings (socketpair, recvmsg with
|
||||
SCM_RIGHTS, ioctl). Dart-team maintained; zero transitive deps.
|
||||
|
||||
- name: tree-sitter
|
||||
kind: native-shared-lib
|
||||
version: "0.26.8"
|
||||
homepage: https://github.com/tree-sitter/tree-sitter
|
||||
license: MIT
|
||||
purpose: >-
|
||||
Incremental parsing library with embedded WASM grammar engine.
|
||||
Vendored as libtree-sitter.so (wasmtime statically linked) in
|
||||
app/native/. Called via dart:ffi. Loads grammar .wasm files
|
||||
through its built-in WASM store API.
|
||||
|
||||
- name: wasmtime
|
||||
kind: native-static-lib
|
||||
version: "44.0.0"
|
||||
homepage: https://github.com/bytecodealliance/wasmtime
|
||||
license: Apache-2.0 with LLVM exception
|
||||
purpose: >-
|
||||
WebAssembly runtime. Statically linked into libtree-sitter.so to
|
||||
provide grammar WASM loading. Not called directly — tree-sitter's
|
||||
C API wraps it.
|
||||
|
||||
- name: tree-sitter grammars
|
||||
kind: wasm-assets
|
||||
version: various
|
||||
homepage: https://github.com/tree-sitter
|
||||
license: MIT (most); Apache-2.0 (elixir, erlang, hcl, just)
|
||||
purpose: >-
|
||||
Language parsers for syntax highlighting. 47 grammars compiled to
|
||||
WASM via wasi-sdk, loaded at runtime by tree-sitter's embedded
|
||||
wasmtime engine. Source repos are tree-sitter/tree-sitter-<lang>
|
||||
on GitHub; sqlite is dhcmrlchtdj/tree-sitter-sqlite (MIT).
|
||||
|
||||
# Build-time-only dependencies — test runners, mocks, lints. Tracked
|
||||
# here for audit completeness; NOT rendered in the About screen.
|
||||
dev_dependencies:
|
||||
|
||||
@@ -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 "^-")
|
||||
)
|
||||
@@ -0,0 +1,213 @@
|
||||
(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))
|
||||
@@ -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
|
||||
@@ -0,0 +1,4 @@
|
||||
(tag) @keyword
|
||||
(name) @constant
|
||||
(user) @string
|
||||
(uri) @text.uri
|
||||
@@ -0,0 +1,77 @@
|
||||
; 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)
|
||||
|
||||
; Modules
|
||||
(module_name
|
||||
(identifier) @module)
|
||||
|
||||
; 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"
|
||||
"import"
|
||||
"export"
|
||||
"module"
|
||||
] @keyword
|
||||
|
||||
; Strings
|
||||
|
||||
(raw_string_literal) @string
|
||||
@@ -0,0 +1,76 @@
|
||||
(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)
|
||||
|
||||
((property_name) @variable
|
||||
(#match? @variable "^--"))
|
||||
((plain_value) @variable
|
||||
(#match? @variable "^--"))
|
||||
|
||||
(class_name) @property
|
||||
(id_name) @property
|
||||
(namespace_name) @property
|
||||
(property_name) @property
|
||||
(feature_name) @property
|
||||
|
||||
(pseudo_element_selector (tag_name) @attribute)
|
||||
(pseudo_class_selector (class_name) @attribute)
|
||||
(attribute_name) @attribute
|
||||
|
||||
(function_name) @function
|
||||
|
||||
"@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.bracket
|
||||
@@ -0,0 +1,246 @@
|
||||
; Variable
|
||||
(identifier) @variable
|
||||
|
||||
; Keywords
|
||||
; --------------------
|
||||
[
|
||||
(assert_builtin)
|
||||
(break_builtin)
|
||||
(const_builtin)
|
||||
(part_of_builtin)
|
||||
(rethrow_builtin)
|
||||
(void_type)
|
||||
"abstract"
|
||||
"as"
|
||||
"async"
|
||||
"async*"
|
||||
"await"
|
||||
"base"
|
||||
"case"
|
||||
"catch"
|
||||
"class"
|
||||
"continue"
|
||||
"covariant"
|
||||
"default"
|
||||
"deferred"
|
||||
"do"
|
||||
"else"
|
||||
"enum"
|
||||
"export"
|
||||
"extends"
|
||||
"extension"
|
||||
"external"
|
||||
"factory"
|
||||
"final"
|
||||
"finally"
|
||||
"for"
|
||||
"Function"
|
||||
"hide"
|
||||
"if"
|
||||
"implements"
|
||||
"import"
|
||||
"in"
|
||||
"interface"
|
||||
"is"
|
||||
"late"
|
||||
"library"
|
||||
"mixin"
|
||||
"new"
|
||||
"on"
|
||||
"operator"
|
||||
"part"
|
||||
"required"
|
||||
"return"
|
||||
"sealed"
|
||||
"show"
|
||||
"static"
|
||||
"super"
|
||||
"switch"
|
||||
"sync*"
|
||||
"throw"
|
||||
"try"
|
||||
"typedef"
|
||||
"var"
|
||||
"when"
|
||||
"while"
|
||||
"with"
|
||||
"yield"
|
||||
] @keyword
|
||||
|
||||
; Methods
|
||||
; --------------------
|
||||
|
||||
; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't
|
||||
; specifically identify a node as a function call
|
||||
(((identifier) @function (#match? @function "^_?[a-z]"))
|
||||
. (selector . (argument_part))) @function
|
||||
|
||||
; Operators and Tokens
|
||||
; --------------------
|
||||
(template_substitution
|
||||
"$" @punctuation.special
|
||||
"{" @punctuation.special
|
||||
"}" @punctuation.special
|
||||
) @none
|
||||
|
||||
(template_substitution
|
||||
"$" @punctuation.special
|
||||
(identifier_dollar_escaped) @variable
|
||||
) @none
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
[
|
||||
"@"
|
||||
"=>"
|
||||
".."
|
||||
"??"
|
||||
"=="
|
||||
"?"
|
||||
":"
|
||||
"&&"
|
||||
"%"
|
||||
"<"
|
||||
">"
|
||||
"="
|
||||
">="
|
||||
"<="
|
||||
"||"
|
||||
"~/"
|
||||
(increment_operator)
|
||||
(is_operator)
|
||||
(prefix_operator)
|
||||
(equality_operator)
|
||||
(additive_operator)
|
||||
] @operator
|
||||
|
||||
(type_arguments
|
||||
"<" @punctuation.bracket
|
||||
">" @punctuation.bracket)
|
||||
|
||||
(type_parameters
|
||||
"<" @punctuation.bracket
|
||||
">" @punctuation.bracket)
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
; Delimiters
|
||||
; --------------------
|
||||
[
|
||||
";"
|
||||
"."
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Types
|
||||
; --------------------
|
||||
(type_identifier) @type
|
||||
((type_identifier) @type.builtin
|
||||
(#match? @type.builtin "^(int|double|String|bool|List|Set|Map|Runes|Symbol)$"))
|
||||
(class_definition
|
||||
name: (identifier) @type)
|
||||
(constructor_signature
|
||||
name: (identifier) @type)
|
||||
(scoped_identifier
|
||||
scope: (identifier) @type)
|
||||
(function_signature
|
||||
name: (identifier) @function)
|
||||
(getter_signature
|
||||
"get" @keyword
|
||||
(identifier) @function)
|
||||
(setter_signature
|
||||
"set" @keyword
|
||||
name: (identifier) @function)
|
||||
|
||||
((scoped_identifier
|
||||
scope: (identifier) @type
|
||||
name: (identifier) @type)
|
||||
(#match? @type "^[a-zA-Z]"))
|
||||
|
||||
; Enums
|
||||
; -------------------
|
||||
(enum_declaration
|
||||
name: (identifier) @type)
|
||||
(enum_constant
|
||||
name: (identifier) @identifier.constant)
|
||||
|
||||
; Variables
|
||||
; --------------------
|
||||
; var keyword
|
||||
(inferred_type) @keyword
|
||||
|
||||
((identifier) @type
|
||||
(#match? @type "^_?[A-Z].*[a-z]"))
|
||||
|
||||
("Function" @type)
|
||||
|
||||
(this) @variable.builtin
|
||||
|
||||
; properties
|
||||
|
||||
(unconditional_assignable_selector
|
||||
(identifier) @property)
|
||||
|
||||
(conditional_assignable_selector
|
||||
(identifier) @property)
|
||||
|
||||
(cascade_section
|
||||
(cascade_selector
|
||||
(identifier) @property))
|
||||
|
||||
((selector
|
||||
(unconditional_assignable_selector (identifier) @function))
|
||||
(selector (argument_part (arguments)))
|
||||
)
|
||||
|
||||
(cascade_section
|
||||
(cascade_selector (identifier) @function)
|
||||
(argument_part (arguments))
|
||||
)
|
||||
|
||||
; assignments
|
||||
(assignment_expression
|
||||
left: (assignable_expression) @variable)
|
||||
|
||||
(this) @variable.builtin
|
||||
|
||||
; Parameters
|
||||
; --------------------
|
||||
(formal_parameter
|
||||
name: (identifier) @identifier.parameter)
|
||||
|
||||
(named_argument
|
||||
(label (identifier) @identifier.parameter))
|
||||
|
||||
; Literals
|
||||
; --------------------
|
||||
[
|
||||
(hex_integer_literal)
|
||||
(decimal_integer_literal)
|
||||
(decimal_floating_point_literal)
|
||||
; TODO: inaccessbile nodes
|
||||
; (octal_integer_literal)
|
||||
; (hex_floating_point_literal)
|
||||
] @number
|
||||
|
||||
(string_literal) @string
|
||||
(symbol_literal (identifier) @constant) @constant
|
||||
(true) @boolean
|
||||
(false) @boolean
|
||||
(null_literal) @constant.null
|
||||
|
||||
(documentation_comment) @comment
|
||||
(comment) @comment
|
||||
|
||||
; Annotations
|
||||
; --------------------
|
||||
(annotation
|
||||
"@" @attribute
|
||||
name: (identifier) @attribute)
|
||||
@@ -0,0 +1,49 @@
|
||||
(comment) @comment @spell
|
||||
|
||||
[
|
||||
(addition)
|
||||
(new_file)
|
||||
] @diff.plus
|
||||
|
||||
[
|
||||
(deletion)
|
||||
(old_file)
|
||||
] @diff.minus
|
||||
|
||||
(commit) @constant
|
||||
|
||||
(location) @attribute
|
||||
|
||||
(command
|
||||
"diff" @function
|
||||
(argument) @variable.parameter)
|
||||
|
||||
(filename) @string.special.path
|
||||
|
||||
(mode) @number
|
||||
|
||||
([
|
||||
".."
|
||||
"+"
|
||||
"++"
|
||||
"+++"
|
||||
"++++"
|
||||
"-"
|
||||
"--"
|
||||
"---"
|
||||
"----"
|
||||
] @punctuation.special
|
||||
(#set! priority 95))
|
||||
|
||||
[
|
||||
(binary_change)
|
||||
(similarity)
|
||||
(file_change)
|
||||
] @label
|
||||
|
||||
(index
|
||||
"index" @keyword)
|
||||
|
||||
(similarity
|
||||
(score) @number
|
||||
"%" @number)
|
||||
@@ -0,0 +1,58 @@
|
||||
[
|
||||
"FROM"
|
||||
"AS"
|
||||
"RUN"
|
||||
"CMD"
|
||||
"LABEL"
|
||||
"EXPOSE"
|
||||
"ENV"
|
||||
"ADD"
|
||||
"COPY"
|
||||
"ENTRYPOINT"
|
||||
"VOLUME"
|
||||
"USER"
|
||||
"WORKDIR"
|
||||
"ARG"
|
||||
"ONBUILD"
|
||||
"STOPSIGNAL"
|
||||
"HEALTHCHECK"
|
||||
"SHELL"
|
||||
"MAINTAINER"
|
||||
"CROSS_BUILD"
|
||||
(heredoc_marker)
|
||||
(heredoc_end)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
":"
|
||||
"@"
|
||||
] @operator
|
||||
|
||||
(comment) @comment
|
||||
|
||||
|
||||
(image_spec
|
||||
(image_tag
|
||||
":" @punctuation.special)
|
||||
(image_digest
|
||||
"@" @punctuation.special))
|
||||
|
||||
[
|
||||
(double_quoted_string)
|
||||
(single_quoted_string)
|
||||
(json_string)
|
||||
(heredoc_line)
|
||||
] @string
|
||||
|
||||
(expansion
|
||||
[
|
||||
"$"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.special
|
||||
) @none
|
||||
|
||||
((variable) @constant
|
||||
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
||||
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
; Punctuation
|
||||
|
||||
[
|
||||
"%"
|
||||
] @punctuation
|
||||
|
||||
[
|
||||
","
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"<<"
|
||||
">>"
|
||||
] @punctuation.bracket
|
||||
|
||||
; Literals
|
||||
|
||||
[
|
||||
(boolean)
|
||||
(nil)
|
||||
] @constant
|
||||
|
||||
[
|
||||
(integer)
|
||||
(float)
|
||||
] @number
|
||||
|
||||
(char) @constant
|
||||
|
||||
; Identifiers
|
||||
|
||||
; * regular
|
||||
(identifier) @variable
|
||||
|
||||
; * unused
|
||||
(
|
||||
(identifier) @comment.unused
|
||||
(#match? @comment.unused "^_")
|
||||
)
|
||||
|
||||
; * special
|
||||
(
|
||||
(identifier) @constant.builtin
|
||||
(#any-of? @constant.builtin "__MODULE__" "__DIR__" "__ENV__" "__CALLER__" "__STACKTRACE__")
|
||||
)
|
||||
|
||||
; Comment
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; Quoted content
|
||||
|
||||
(interpolation "#{" @punctuation.special "}" @punctuation.special) @embedded
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
[
|
||||
(string)
|
||||
(charlist)
|
||||
] @string
|
||||
|
||||
[
|
||||
(atom)
|
||||
(quoted_atom)
|
||||
(keyword)
|
||||
(quoted_keyword)
|
||||
] @string.special.symbol
|
||||
|
||||
; Note that we explicitly target sigil quoted start/end, so they are not overridden by delimiters
|
||||
|
||||
(sigil
|
||||
(sigil_name) @__name__
|
||||
quoted_start: _ @string.special
|
||||
quoted_end: _ @string.special) @string.special
|
||||
|
||||
(sigil
|
||||
(sigil_name) @__name__
|
||||
quoted_start: _ @string
|
||||
quoted_end: _ @string
|
||||
(#match? @__name__ "^[sS]$")) @string
|
||||
|
||||
(sigil
|
||||
(sigil_name) @__name__
|
||||
quoted_start: _ @string.regex
|
||||
quoted_end: _ @string.regex
|
||||
(#match? @__name__ "^[rR]$")) @string.regex
|
||||
|
||||
; Calls
|
||||
|
||||
; * local function call
|
||||
(call
|
||||
target: (identifier) @function)
|
||||
|
||||
; * remote function call
|
||||
(call
|
||||
target: (dot
|
||||
right: (identifier) @function))
|
||||
|
||||
; * field without parentheses or block
|
||||
(call
|
||||
target: (dot
|
||||
right: (identifier) @property)
|
||||
.)
|
||||
|
||||
; * remote call without parentheses or block (overrides above)
|
||||
(call
|
||||
target: (dot
|
||||
left: [
|
||||
(alias)
|
||||
(atom)
|
||||
]
|
||||
right: (identifier) @function)
|
||||
.)
|
||||
|
||||
; * definition keyword
|
||||
(call
|
||||
target: (identifier) @keyword
|
||||
(#any-of? @keyword "def" "defdelegate" "defexception" "defguard" "defguardp" "defimpl" "defmacro" "defmacrop" "defmodule" "defn" "defnp" "defoverridable" "defp" "defprotocol" "defstruct"))
|
||||
|
||||
; * kernel or special forms keyword
|
||||
(call
|
||||
target: (identifier) @keyword
|
||||
(#any-of? @keyword "alias" "case" "cond" "for" "if" "import" "quote" "raise" "receive" "require" "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))
|
||||
|
||||
; * just identifier in function definition
|
||||
(call
|
||||
target: (identifier) @keyword
|
||||
(arguments
|
||||
[
|
||||
(identifier) @function
|
||||
(binary_operator
|
||||
left: (identifier) @function
|
||||
operator: "when")
|
||||
])
|
||||
(#any-of? @keyword "def" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defp"))
|
||||
|
||||
; * pipe into identifier (function call)
|
||||
(binary_operator
|
||||
operator: "|>"
|
||||
right: (identifier) @function)
|
||||
|
||||
; * pipe into identifier (definition)
|
||||
(call
|
||||
target: (identifier) @keyword
|
||||
(arguments
|
||||
(binary_operator
|
||||
operator: "|>"
|
||||
right: (identifier) @variable))
|
||||
(#any-of? @keyword "def" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defp"))
|
||||
|
||||
; * pipe into field without parentheses (function call)
|
||||
(binary_operator
|
||||
operator: "|>"
|
||||
right: (call
|
||||
target: (dot
|
||||
right: (identifier) @function)))
|
||||
|
||||
; Operators
|
||||
|
||||
; * capture operand
|
||||
(unary_operator
|
||||
operator: "&"
|
||||
operand: (integer) @operator)
|
||||
|
||||
(operator_identifier) @operator
|
||||
|
||||
(unary_operator
|
||||
operator: _ @operator)
|
||||
|
||||
(binary_operator
|
||||
operator: _ @operator)
|
||||
|
||||
(dot
|
||||
operator: _ @operator)
|
||||
|
||||
(stab_clause
|
||||
operator: _ @operator)
|
||||
|
||||
; * module attribute
|
||||
(unary_operator
|
||||
operator: "@" @attribute
|
||||
operand: [
|
||||
(identifier) @attribute
|
||||
(call
|
||||
target: (identifier) @attribute)
|
||||
(boolean) @attribute
|
||||
(nil) @attribute
|
||||
])
|
||||
|
||||
; * doc string
|
||||
(unary_operator
|
||||
operator: "@" @comment.doc
|
||||
operand: (call
|
||||
target: (identifier) @comment.doc.__attribute__
|
||||
(arguments
|
||||
[
|
||||
(string) @comment.doc
|
||||
(charlist) @comment.doc
|
||||
(sigil
|
||||
quoted_start: _ @comment.doc
|
||||
quoted_end: _ @comment.doc) @comment.doc
|
||||
(boolean) @comment.doc
|
||||
]))
|
||||
(#any-of? @comment.doc.__attribute__ "moduledoc" "typedoc" "doc"))
|
||||
|
||||
; Module
|
||||
|
||||
(alias) @module
|
||||
|
||||
(call
|
||||
target: (dot
|
||||
left: (atom) @module))
|
||||
|
||||
; Reserved keywords
|
||||
|
||||
["when" "and" "or" "not" "in" "not in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword
|
||||
@@ -0,0 +1,46 @@
|
||||
[
|
||||
"fun" "end"
|
||||
"if" "case" "of" "when"
|
||||
"receive" "after"
|
||||
"try" "catch" "throw"
|
||||
"begin"
|
||||
"module" "export" "import"
|
||||
"record" "spec" "type" "opaque" "callback"
|
||||
"define" "include" "include_lib"
|
||||
"ifdef" "ifndef" "else" "endif" "undef"
|
||||
"not" "and" "or" "andalso" "orelse"
|
||||
"band" "bor" "bxor" "bnot" "bsl" "bsr"
|
||||
"div" "rem"
|
||||
] @keyword
|
||||
|
||||
(atom) @string
|
||||
(string) @string
|
||||
(char) @string
|
||||
|
||||
(integer) @number
|
||||
(float) @number
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(function_clause (atom) @function)
|
||||
(call (atom) @function)
|
||||
(attribute (atom) @attribute)
|
||||
|
||||
(variable) @variable
|
||||
(macro) @constant
|
||||
|
||||
[
|
||||
"(" ")" "[" "]" "{" "}" "<<" ">>"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"," "." ";" ":" "|" "->" "=>" "::"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"=" "==" "=:=" "=/=" "/="
|
||||
"+" "-" "*" "/"
|
||||
"<" ">" "=<" ">="
|
||||
"++" "--"
|
||||
"!" "#"
|
||||
] @operator
|
||||
@@ -0,0 +1,59 @@
|
||||
[
|
||||
"if" "elif" "else"
|
||||
"for" "while"
|
||||
"match"
|
||||
"break" "continue" "pass"
|
||||
"return"
|
||||
"class" "class_name" "extends"
|
||||
"func" "static" "const" "var" "onready"
|
||||
"signal" "export" "enum"
|
||||
"await" "yield"
|
||||
"in" "is" "as" "not" "and" "or"
|
||||
"true" "false" "null"
|
||||
"self"
|
||||
"breakpoint"
|
||||
"preload" "load"
|
||||
] @keyword
|
||||
|
||||
(function_definition (name) @function)
|
||||
(constructor_definition (name) @function)
|
||||
(call (name) @function)
|
||||
(attribute_call (name) @function)
|
||||
|
||||
(class_definition (name) @type)
|
||||
(type) @type
|
||||
(class_name_statement (name) @type)
|
||||
|
||||
(string) @string
|
||||
(node_path) @string
|
||||
(string_name) @string
|
||||
(escape_sequence) @string.special
|
||||
|
||||
(integer) @number
|
||||
(float) @number
|
||||
(true) @boolean
|
||||
(false) @boolean
|
||||
(null) @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(identifier) @variable
|
||||
(attribute) @property
|
||||
|
||||
(annotation) @attribute
|
||||
|
||||
[
|
||||
"(" ")" "[" "]" "{" "}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"," "." ":" "->" ";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"=" "+=" "-=" "*=" "/=" "%="
|
||||
"+" "-" "*" "/" "%"
|
||||
"==" "!=" "<" ">" "<=" ">="
|
||||
"&&" "||" "!"
|
||||
"&" "|" "^" "~" "<<" ">>"
|
||||
] @operator
|
||||
@@ -0,0 +1,28 @@
|
||||
(section_name) @tag
|
||||
|
||||
((section_name) @function.builtin
|
||||
(#eq? @function.builtin "include"))
|
||||
|
||||
((section_header
|
||||
(section_name) @function.builtin
|
||||
(subsection_name))
|
||||
(#eq? @function.builtin "includeIf"))
|
||||
|
||||
(variable (name) @property)
|
||||
[(true) (false)] @constant.builtin
|
||||
(integer) @number
|
||||
|
||||
[(string) (subsection_name)] @string
|
||||
|
||||
((string) @string.special.path
|
||||
(#match? @string.special.path "^(~|./|/)"))
|
||||
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"\""
|
||||
] @punctuation.bracket
|
||||
|
||||
"=" @punctuation.delimiter
|
||||
|
||||
(comment) @comment
|
||||
@@ -0,0 +1,4 @@
|
||||
(pattern) @string
|
||||
(negation) @operator
|
||||
(comment) @comment
|
||||
(directory_separator) @punctuation.delimiter
|
||||
@@ -0,0 +1,115 @@
|
||||
"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
|
||||
|
||||
(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)
|
||||
|
||||
(field_identifier) @property
|
||||
(statement_identifier) @label
|
||||
(type_identifier) @type
|
||||
(primitive_type) @type
|
||||
(sized_type_specifier) @type
|
||||
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
(comment) @comment
|
||||
; inherits: c
|
||||
[
|
||||
"in"
|
||||
"out"
|
||||
"inout"
|
||||
"uniform"
|
||||
"shared"
|
||||
"layout"
|
||||
"attribute"
|
||||
"varying"
|
||||
"buffer"
|
||||
"coherent"
|
||||
"readonly"
|
||||
"writeonly"
|
||||
"precision"
|
||||
"highp"
|
||||
"mediump"
|
||||
"lowp"
|
||||
"centroid"
|
||||
"sample"
|
||||
"patch"
|
||||
"smooth"
|
||||
"flat"
|
||||
"noperspective"
|
||||
"invariant"
|
||||
"precise"
|
||||
] @type.qualifier
|
||||
|
||||
"subroutine" @keyword.function
|
||||
|
||||
(extension_storage_class) @keyword.storage
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#lua-match? @variable.builtin "^gl_"))
|
||||
@@ -0,0 +1,123 @@
|
||||
; Function calls
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function.builtin
|
||||
(#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$"))
|
||||
|
||||
(call_expression
|
||||
function: (selector_expression
|
||||
field: (field_identifier) @function.method))
|
||||
|
||||
; Function definitions
|
||||
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
(method_declaration
|
||||
name: (field_identifier) @function.method)
|
||||
|
||||
; Identifiers
|
||||
|
||||
(type_identifier) @type
|
||||
(field_identifier) @property
|
||||
(identifier) @variable
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"--"
|
||||
"-"
|
||||
"-="
|
||||
":="
|
||||
"!"
|
||||
"!="
|
||||
"..."
|
||||
"*"
|
||||
"*"
|
||||
"*="
|
||||
"/"
|
||||
"/="
|
||||
"&"
|
||||
"&&"
|
||||
"&="
|
||||
"%"
|
||||
"%="
|
||||
"^"
|
||||
"^="
|
||||
"+"
|
||||
"++"
|
||||
"+="
|
||||
"<-"
|
||||
"<"
|
||||
"<<"
|
||||
"<<="
|
||||
"<="
|
||||
"="
|
||||
"=="
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
">>="
|
||||
"|"
|
||||
"|="
|
||||
"||"
|
||||
"~"
|
||||
] @operator
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"break"
|
||||
"case"
|
||||
"chan"
|
||||
"const"
|
||||
"continue"
|
||||
"default"
|
||||
"defer"
|
||||
"else"
|
||||
"fallthrough"
|
||||
"for"
|
||||
"func"
|
||||
"go"
|
||||
"goto"
|
||||
"if"
|
||||
"import"
|
||||
"interface"
|
||||
"map"
|
||||
"package"
|
||||
"range"
|
||||
"return"
|
||||
"select"
|
||||
"struct"
|
||||
"switch"
|
||||
"type"
|
||||
"var"
|
||||
] @keyword
|
||||
|
||||
; Literals
|
||||
|
||||
[
|
||||
(interpreted_string_literal)
|
||||
(raw_string_literal)
|
||||
(rune_literal)
|
||||
] @string
|
||||
|
||||
(escape_sequence) @escape
|
||||
|
||||
[
|
||||
(int_literal)
|
||||
(float_literal)
|
||||
(imaginary_literal)
|
||||
] @number
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
(nil)
|
||||
(iota)
|
||||
] @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
@@ -0,0 +1,443 @@
|
||||
; ----------------------------------------------------------------------------
|
||||
; Parameters and variables
|
||||
; NOTE: These are at the top, so that they have low priority,
|
||||
; and don't override destructured parameters
|
||||
(variable) @variable
|
||||
|
||||
(pattern/wildcard) @variable
|
||||
|
||||
(decl/function
|
||||
patterns: (patterns
|
||||
(_) @variable.parameter))
|
||||
|
||||
(expression/lambda
|
||||
(_)+ @variable.parameter
|
||||
"->")
|
||||
|
||||
(decl/function
|
||||
(infix
|
||||
(pattern) @variable.parameter))
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; Literals and comments
|
||||
(integer) @number
|
||||
|
||||
(negation) @number
|
||||
|
||||
(expression/literal
|
||||
(float)) @number.float
|
||||
|
||||
(char) @character
|
||||
|
||||
(string) @string
|
||||
|
||||
(unit) @string.special.symbol ; unit, as in ()
|
||||
|
||||
(comment) @comment
|
||||
|
||||
((haddock) @comment.documentation)
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; Punctuation
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
","
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; Keywords, operators, includes
|
||||
[
|
||||
"forall"
|
||||
; "∀" ; utf-8 is not cross-platform safe
|
||||
] @keyword.repeat
|
||||
|
||||
(pragma) @keyword.directive
|
||||
|
||||
[
|
||||
"if"
|
||||
"then"
|
||||
"else"
|
||||
"case"
|
||||
"of"
|
||||
] @keyword.conditional
|
||||
|
||||
[
|
||||
"import"
|
||||
"qualified"
|
||||
"module"
|
||||
] @keyword.import
|
||||
|
||||
[
|
||||
(operator)
|
||||
(constructor_operator)
|
||||
(all_names)
|
||||
(wildcard)
|
||||
"."
|
||||
".."
|
||||
"="
|
||||
"|"
|
||||
"::"
|
||||
"=>"
|
||||
"->"
|
||||
"<-"
|
||||
"\\"
|
||||
"`"
|
||||
"@"
|
||||
] @operator
|
||||
|
||||
; TODO broken, also huh?
|
||||
; ((qualified_module
|
||||
; (module) @constructor)
|
||||
; .
|
||||
; (module))
|
||||
|
||||
(module
|
||||
(module_id) @module)
|
||||
|
||||
[
|
||||
"where"
|
||||
"let"
|
||||
"in"
|
||||
"class"
|
||||
"instance"
|
||||
"pattern"
|
||||
"data"
|
||||
"newtype"
|
||||
"family"
|
||||
"type"
|
||||
"as"
|
||||
"hiding"
|
||||
"deriving"
|
||||
"via"
|
||||
"stock"
|
||||
"anyclass"
|
||||
"do"
|
||||
"mdo"
|
||||
"rec"
|
||||
"infix"
|
||||
"infixl"
|
||||
"infixr"
|
||||
] @keyword
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; Functions and variables
|
||||
(decl
|
||||
[
|
||||
name: (variable) @function
|
||||
names: (binding_list (variable) @function)
|
||||
])
|
||||
|
||||
(decl/bind
|
||||
name: (variable) @variable)
|
||||
|
||||
; Consider signatures (and accompanying functions)
|
||||
; with only one value on the rhs as variables
|
||||
(decl/signature
|
||||
name: (variable) @variable
|
||||
type: (type))
|
||||
|
||||
((decl/signature
|
||||
name: (variable) @_name
|
||||
type: (type))
|
||||
.
|
||||
(decl
|
||||
name: (variable) @variable)
|
||||
match: (_)
|
||||
(#eq? @_name @variable))
|
||||
|
||||
; but consider a type that involves 'IO' a decl/function
|
||||
(decl/signature
|
||||
name: (variable) @function
|
||||
type: (type/apply
|
||||
constructor: (name) @_type)
|
||||
(#eq? @_type "IO"))
|
||||
|
||||
((decl/signature
|
||||
name: (variable) @_name
|
||||
type: (type/apply
|
||||
constructor: (name) @_type)
|
||||
(#eq? @_type "IO"))
|
||||
.
|
||||
(decl
|
||||
name: (variable) @function)
|
||||
match: (_)
|
||||
(#eq? @_name @function))
|
||||
|
||||
((decl/signature) @function
|
||||
.
|
||||
(decl/function
|
||||
name: (variable) @function))
|
||||
|
||||
(decl/bind
|
||||
name: (variable) @function
|
||||
(match
|
||||
expression: (expression/lambda)))
|
||||
|
||||
; view patterns
|
||||
(view_pattern
|
||||
[
|
||||
(expression/variable) @function.call
|
||||
(expression/qualified
|
||||
(variable) @function.call)
|
||||
])
|
||||
|
||||
; consider infix functions as operators
|
||||
(infix_id
|
||||
[
|
||||
(variable) @operator
|
||||
(qualified
|
||||
(variable) @operator)
|
||||
])
|
||||
|
||||
; decl/function calls with an infix operator
|
||||
; e.g. func <$> a <*> b
|
||||
(infix
|
||||
[
|
||||
(variable) @function.call
|
||||
(qualified
|
||||
((module) @module
|
||||
(variable) @function.call))
|
||||
]
|
||||
.
|
||||
(operator))
|
||||
|
||||
; infix operators applied to variables
|
||||
((expression/variable) @variable
|
||||
.
|
||||
(operator))
|
||||
|
||||
((operator)
|
||||
.
|
||||
[
|
||||
(expression/variable) @variable
|
||||
(expression/qualified
|
||||
(variable) @variable)
|
||||
])
|
||||
|
||||
; decl/function calls with infix operators
|
||||
([
|
||||
(expression/variable) @function.call
|
||||
(expression/qualified
|
||||
(variable) @function.call)
|
||||
]
|
||||
.
|
||||
(operator) @_op
|
||||
(#any-of? @_op "$" "<$>" ">>=" "=<<"))
|
||||
|
||||
; right hand side of infix operator
|
||||
((infix
|
||||
[
|
||||
(operator)
|
||||
(infix_id (variable))
|
||||
] ; infix or `func`
|
||||
.
|
||||
[
|
||||
(variable) @function.call
|
||||
(qualified
|
||||
(variable) @function.call)
|
||||
])
|
||||
.
|
||||
(operator) @_op
|
||||
(#any-of? @_op "$" "<$>" "=<<"))
|
||||
|
||||
; decl/function composition, arrows, monadic composition (lhs)
|
||||
(
|
||||
[
|
||||
(expression/variable) @function
|
||||
(expression/qualified
|
||||
(variable) @function)
|
||||
]
|
||||
.
|
||||
(operator) @_op
|
||||
(#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
|
||||
|
||||
; right hand side of infix operator
|
||||
((infix
|
||||
[
|
||||
(operator)
|
||||
(infix_id (variable))
|
||||
] ; infix or `func`
|
||||
.
|
||||
[
|
||||
(variable) @function
|
||||
(qualified
|
||||
(variable) @function)
|
||||
])
|
||||
.
|
||||
(operator) @_op
|
||||
(#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
|
||||
|
||||
; function composition, arrows, monadic composition (rhs)
|
||||
((operator) @_op
|
||||
.
|
||||
[
|
||||
(expression/variable) @function
|
||||
(expression/qualified
|
||||
(variable) @function)
|
||||
]
|
||||
(#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
|
||||
|
||||
; function defined in terms of a function composition
|
||||
(decl/function
|
||||
name: (variable) @function
|
||||
(match
|
||||
expression: (infix
|
||||
operator: (operator) @_op
|
||||
(#any-of? @_op "." ">>>" "***" ">=>" "<=<"))))
|
||||
|
||||
(apply
|
||||
[
|
||||
(expression/variable) @function.call
|
||||
(expression/qualified
|
||||
(variable) @function.call)
|
||||
])
|
||||
|
||||
; function compositions, in parentheses, applied
|
||||
; lhs
|
||||
(apply
|
||||
.
|
||||
(expression/parens
|
||||
(infix
|
||||
[
|
||||
(variable) @function.call
|
||||
(qualified
|
||||
(variable) @function.call)
|
||||
]
|
||||
.
|
||||
(operator))))
|
||||
|
||||
; rhs
|
||||
(apply
|
||||
.
|
||||
(expression/parens
|
||||
(infix
|
||||
(operator)
|
||||
.
|
||||
[
|
||||
(variable) @function.call
|
||||
(qualified
|
||||
(variable) @function.call)
|
||||
])))
|
||||
|
||||
; variables being passed to a function call
|
||||
(apply
|
||||
(_)
|
||||
.
|
||||
[
|
||||
(expression/variable) @variable
|
||||
(expression/qualified
|
||||
(variable) @variable)
|
||||
])
|
||||
|
||||
; main is always a function
|
||||
; (this prevents `main = undefined` from being highlighted as a variable)
|
||||
(decl/bind
|
||||
name: (variable) @function
|
||||
(#eq? @function "main"))
|
||||
|
||||
; scoped function types (func :: a -> b)
|
||||
(signature
|
||||
pattern: (pattern/variable) @function
|
||||
type: (quantified_type))
|
||||
|
||||
; signatures that have a function type
|
||||
; + binds that follow them
|
||||
(decl/signature
|
||||
name: (variable) @function
|
||||
type: (quantified_type))
|
||||
|
||||
((decl/signature
|
||||
name: (variable) @_name
|
||||
type: (quantified_type))
|
||||
.
|
||||
(decl/bind
|
||||
(variable) @function)
|
||||
(#eq? @function @_name))
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; Types
|
||||
(name) @type
|
||||
|
||||
(type/star) @type
|
||||
|
||||
(variable) @type
|
||||
|
||||
(constructor) @constructor
|
||||
|
||||
; True or False
|
||||
((constructor) @boolean
|
||||
(#any-of? @boolean "True" "False"))
|
||||
|
||||
; otherwise (= True)
|
||||
((variable) @boolean
|
||||
(#eq? @boolean "otherwise"))
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; Quasi-quotes
|
||||
(quoter) @function.call
|
||||
|
||||
(quasiquote
|
||||
[
|
||||
(quoter) @_name
|
||||
(_
|
||||
(variable) @_name)
|
||||
]
|
||||
(#eq? @_name "qq")
|
||||
(quasiquote_body) @string)
|
||||
|
||||
(quasiquote
|
||||
(_
|
||||
(variable) @_name)
|
||||
(#eq? @_name "qq")
|
||||
(quasiquote_body) @string)
|
||||
|
||||
; namespaced quasi-quoter
|
||||
(quasiquote
|
||||
(_
|
||||
(module) @module
|
||||
.
|
||||
(variable) @function.call))
|
||||
|
||||
; Highlighting of quasiquote_body for other languages is handled by injections.scm
|
||||
; ----------------------------------------------------------------------------
|
||||
; Exceptions/error handling
|
||||
((variable) @keyword.exception
|
||||
(#any-of? @keyword.exception
|
||||
"error" "undefined" "try" "tryJust" "tryAny" "catch" "catches" "catchJust" "handle" "handleJust"
|
||||
"throw" "throwIO" "throwTo" "throwError" "ioError" "mask" "mask_" "uninterruptibleMask"
|
||||
"uninterruptibleMask_" "bracket" "bracket_" "bracketOnErrorSource" "finally" "fail"
|
||||
"onException" "expectationFailure"))
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; Debugging
|
||||
((variable) @keyword.debug
|
||||
(#any-of? @keyword.debug
|
||||
"trace" "traceId" "traceShow" "traceShowId" "traceWith" "traceShowWith" "traceStack" "traceIO"
|
||||
"traceM" "traceShowM" "traceEvent" "traceEventWith" "traceEventIO" "flushEventLog" "traceMarker"
|
||||
"traceMarkerIO"))
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; Fields
|
||||
|
||||
(field_name
|
||||
(variable) @variable.member)
|
||||
|
||||
(import_name
|
||||
(name)
|
||||
.
|
||||
(children
|
||||
(variable) @variable.member))
|
||||
|
||||
|
||||
; ----------------------------------------------------------------------------
|
||||
; Spell checking
|
||||
(comment) @spell
|
||||
@@ -0,0 +1,39 @@
|
||||
[
|
||||
"true" "false" "null"
|
||||
"if" "else" "endif"
|
||||
"for" "in" "endfor"
|
||||
] @keyword
|
||||
|
||||
(block (identifier) @keyword)
|
||||
(block (body (block (identifier) @type)))
|
||||
|
||||
(string_lit) @string
|
||||
(template_literal) @string
|
||||
(heredoc_template) @string
|
||||
(template_interpolation) @string.special
|
||||
|
||||
(numeric_lit) @number
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(function_call (identifier) @function)
|
||||
|
||||
(identifier) @variable
|
||||
(variable_expr) @variable
|
||||
|
||||
(attribute (identifier) @property)
|
||||
|
||||
[
|
||||
"(" ")" "[" "]" "{" "}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"." "," ":" "=>"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"=" "==" "!=" "<" ">" "<=" ">="
|
||||
"+" "-" "*" "/" "%"
|
||||
"&&" "||" "!"
|
||||
"?" ":"
|
||||
] @operator
|
||||
@@ -0,0 +1,47 @@
|
||||
[
|
||||
"if" "else"
|
||||
"for" "while" "do"
|
||||
"switch" "case" "default" "break" "continue"
|
||||
"return" "discard"
|
||||
"struct" "typedef" "cbuffer" "tbuffer"
|
||||
"register" "packoffset"
|
||||
"in" "out" "inout"
|
||||
"static" "const" "extern" "volatile"
|
||||
"inline"
|
||||
"true" "false"
|
||||
] @keyword
|
||||
|
||||
(type_identifier) @type
|
||||
(primitive_type) @type.builtin
|
||||
|
||||
(function_declarator (identifier) @function)
|
||||
(call_expression (identifier) @function)
|
||||
|
||||
(string_literal) @string
|
||||
|
||||
(number_literal) @number
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(identifier) @variable
|
||||
(field_expression (identifier) @property)
|
||||
|
||||
(preproc_directive) @keyword
|
||||
(preproc_include) @keyword
|
||||
|
||||
[
|
||||
"(" ")" "[" "]" "{" "}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"," "." ";" ":"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"=" "+=" "-=" "*=" "/=" "%="
|
||||
"+" "-" "*" "/" "%"
|
||||
"==" "!=" "<" ">" "<=" ">="
|
||||
"&&" "||" "!"
|
||||
"&" "|" "^" "~" "<<" ">>"
|
||||
"?" ":"
|
||||
] @operator
|
||||
@@ -0,0 +1,13 @@
|
||||
(tag_name) @tag
|
||||
(erroneous_end_tag_name) @tag.error
|
||||
(doctype) @constant
|
||||
(attribute_name) @attribute
|
||||
(attribute_value) @string
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
"</"
|
||||
"/>"
|
||||
] @punctuation.bracket
|
||||
@@ -0,0 +1,149 @@
|
||||
; Variables
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
; Methods
|
||||
|
||||
(method_declaration
|
||||
name: (identifier) @function.method)
|
||||
(method_invocation
|
||||
name: (identifier) @function.method)
|
||||
(super) @function.builtin
|
||||
|
||||
; Annotations
|
||||
|
||||
(annotation
|
||||
name: (identifier) @attribute)
|
||||
(marker_annotation
|
||||
name: (identifier) @attribute)
|
||||
|
||||
"@" @operator
|
||||
|
||||
; Types
|
||||
|
||||
(type_identifier) @type
|
||||
|
||||
(interface_declaration
|
||||
name: (identifier) @type)
|
||||
(class_declaration
|
||||
name: (identifier) @type)
|
||||
(enum_declaration
|
||||
name: (identifier) @type)
|
||||
|
||||
((field_access
|
||||
object: (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
((scoped_identifier
|
||||
scope: (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
((method_invocation
|
||||
object: (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
((method_reference
|
||||
. (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
(constructor_declaration
|
||||
name: (identifier) @type)
|
||||
|
||||
[
|
||||
(boolean_type)
|
||||
(integral_type)
|
||||
(floating_point_type)
|
||||
(floating_point_type)
|
||||
(void_type)
|
||||
] @type.builtin
|
||||
|
||||
; Constants
|
||||
|
||||
((identifier) @constant
|
||||
(#match? @constant "^_*[A-Z][A-Z\\d_]+$"))
|
||||
|
||||
; Builtins
|
||||
|
||||
(this) @variable.builtin
|
||||
|
||||
; Literals
|
||||
|
||||
[
|
||||
(hex_integer_literal)
|
||||
(decimal_integer_literal)
|
||||
(octal_integer_literal)
|
||||
(decimal_floating_point_literal)
|
||||
(hex_floating_point_literal)
|
||||
] @number
|
||||
|
||||
[
|
||||
(character_literal)
|
||||
(string_literal)
|
||||
] @string
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
(null_literal)
|
||||
] @constant.builtin
|
||||
|
||||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"abstract"
|
||||
"assert"
|
||||
"break"
|
||||
"case"
|
||||
"catch"
|
||||
"class"
|
||||
"continue"
|
||||
"default"
|
||||
"do"
|
||||
"else"
|
||||
"enum"
|
||||
"exports"
|
||||
"extends"
|
||||
"final"
|
||||
"finally"
|
||||
"for"
|
||||
"if"
|
||||
"implements"
|
||||
"import"
|
||||
"instanceof"
|
||||
"interface"
|
||||
"module"
|
||||
"native"
|
||||
"new"
|
||||
"non-sealed"
|
||||
"open"
|
||||
"opens"
|
||||
"package"
|
||||
"permits"
|
||||
"private"
|
||||
"protected"
|
||||
"provides"
|
||||
"public"
|
||||
"requires"
|
||||
"record"
|
||||
"return"
|
||||
"sealed"
|
||||
"static"
|
||||
"strictfp"
|
||||
"switch"
|
||||
"synchronized"
|
||||
"throw"
|
||||
"throws"
|
||||
"to"
|
||||
"transient"
|
||||
"transitive"
|
||||
"try"
|
||||
"uses"
|
||||
"volatile"
|
||||
"when"
|
||||
"while"
|
||||
"with"
|
||||
"yield"
|
||||
] @keyword
|
||||
@@ -0,0 +1,204 @@
|
||||
; Variables
|
||||
;----------
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
; Properties
|
||||
;-----------
|
||||
|
||||
(property_identifier) @property
|
||||
|
||||
; Function and method definitions
|
||||
;--------------------------------
|
||||
|
||||
(function_expression
|
||||
name: (identifier) @function)
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
(method_definition
|
||||
name: (property_identifier) @function.method)
|
||||
|
||||
(pair
|
||||
key: (property_identifier) @function.method
|
||||
value: [(function_expression) (arrow_function)])
|
||||
|
||||
(assignment_expression
|
||||
left: (member_expression
|
||||
property: (property_identifier) @function.method)
|
||||
right: [(function_expression) (arrow_function)])
|
||||
|
||||
(variable_declarator
|
||||
name: (identifier) @function
|
||||
value: [(function_expression) (arrow_function)])
|
||||
|
||||
(assignment_expression
|
||||
left: (identifier) @function
|
||||
right: [(function_expression) (arrow_function)])
|
||||
|
||||
; Function and method calls
|
||||
;--------------------------
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function)
|
||||
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
property: (property_identifier) @function.method))
|
||||
|
||||
; Special identifiers
|
||||
;--------------------
|
||||
|
||||
((identifier) @constructor
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
([
|
||||
(identifier)
|
||||
(shorthand_property_identifier)
|
||||
(shorthand_property_identifier_pattern)
|
||||
] @constant
|
||||
(#match? @constant "^[A-Z_][A-Z\\d_]+$"))
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin "^(arguments|module|console|window|document)$")
|
||||
(#is-not? local))
|
||||
|
||||
((identifier) @function.builtin
|
||||
(#eq? @function.builtin "require")
|
||||
(#is-not? local))
|
||||
|
||||
; Literals
|
||||
;---------
|
||||
|
||||
(this) @variable.builtin
|
||||
(super) @variable.builtin
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
(null)
|
||||
(undefined)
|
||||
] @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
(string)
|
||||
(template_string)
|
||||
] @string
|
||||
|
||||
(regex) @string.special
|
||||
(number) @number
|
||||
|
||||
; Tokens
|
||||
;-------
|
||||
|
||||
[
|
||||
";"
|
||||
(optional_chain)
|
||||
"."
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"-"
|
||||
"--"
|
||||
"-="
|
||||
"+"
|
||||
"++"
|
||||
"+="
|
||||
"*"
|
||||
"*="
|
||||
"**"
|
||||
"**="
|
||||
"/"
|
||||
"/="
|
||||
"%"
|
||||
"%="
|
||||
"<"
|
||||
"<="
|
||||
"<<"
|
||||
"<<="
|
||||
"="
|
||||
"=="
|
||||
"==="
|
||||
"!"
|
||||
"!="
|
||||
"!=="
|
||||
"=>"
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
">>="
|
||||
">>>"
|
||||
">>>="
|
||||
"~"
|
||||
"^"
|
||||
"&"
|
||||
"|"
|
||||
"^="
|
||||
"&="
|
||||
"|="
|
||||
"&&"
|
||||
"||"
|
||||
"??"
|
||||
"&&="
|
||||
"||="
|
||||
"??="
|
||||
] @operator
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
(template_substitution
|
||||
"${" @punctuation.special
|
||||
"}" @punctuation.special) @embedded
|
||||
|
||||
[
|
||||
"as"
|
||||
"async"
|
||||
"await"
|
||||
"break"
|
||||
"case"
|
||||
"catch"
|
||||
"class"
|
||||
"const"
|
||||
"continue"
|
||||
"debugger"
|
||||
"default"
|
||||
"delete"
|
||||
"do"
|
||||
"else"
|
||||
"export"
|
||||
"extends"
|
||||
"finally"
|
||||
"for"
|
||||
"from"
|
||||
"function"
|
||||
"get"
|
||||
"if"
|
||||
"import"
|
||||
"in"
|
||||
"instanceof"
|
||||
"let"
|
||||
"new"
|
||||
"of"
|
||||
"return"
|
||||
"set"
|
||||
"static"
|
||||
"switch"
|
||||
"target"
|
||||
"throw"
|
||||
"try"
|
||||
"typeof"
|
||||
"var"
|
||||
"void"
|
||||
"while"
|
||||
"with"
|
||||
"yield"
|
||||
] @keyword
|
||||
@@ -0,0 +1,16 @@
|
||||
(pair
|
||||
key: (_) @string.special.key)
|
||||
|
||||
(string) @string
|
||||
|
||||
(number) @number
|
||||
|
||||
[
|
||||
(null)
|
||||
(true)
|
||||
(false)
|
||||
] @constant.builtin
|
||||
|
||||
(escape_sequence) @escape
|
||||
|
||||
(comment) @comment
|
||||
@@ -0,0 +1,375 @@
|
||||
; Identifiers
|
||||
(identifier) @variable
|
||||
|
||||
(field_expression
|
||||
(identifier) @variable.member .)
|
||||
|
||||
; Symbols
|
||||
(quote_expression
|
||||
":" @string.special.symbol
|
||||
[
|
||||
(identifier)
|
||||
(operator)
|
||||
] @string.special.symbol)
|
||||
|
||||
; Function calls
|
||||
(call_expression
|
||||
(identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
(field_expression
|
||||
(identifier) @function.call .))
|
||||
|
||||
(broadcast_call_expression
|
||||
(identifier) @function.call)
|
||||
|
||||
(broadcast_call_expression
|
||||
(field_expression
|
||||
(identifier) @function.call .))
|
||||
|
||||
(binary_expression
|
||||
(_)
|
||||
(operator) @_pipe
|
||||
(identifier) @function.call
|
||||
(#any-of? @_pipe "|>" ".|>"))
|
||||
|
||||
; Macros
|
||||
(macro_identifier
|
||||
"@" @function.macro
|
||||
(identifier) @function.macro)
|
||||
|
||||
(macro_definition
|
||||
(signature
|
||||
(call_expression
|
||||
.
|
||||
(identifier) @function.macro)))
|
||||
|
||||
; Built-in functions
|
||||
; print.("\"", filter(name -> getglobal(Core, name) isa Core.Builtin, names(Core)), "\" ")
|
||||
((identifier) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"applicable" "fieldtype" "getfield" "getglobal" "invoke" "isa" "isdefined" "isdefinedglobal"
|
||||
"modifyfield!" "modifyglobal!" "nfields" "replacefield!" "replaceglobal!" "setfield!"
|
||||
"setfieldonce!" "setglobal!" "setglobalonce!" "swapfield!" "swapglobal!" "throw" "tuple"
|
||||
"typeassert" "typeof"))
|
||||
|
||||
; Type definitions
|
||||
(type_head
|
||||
(_) @type.definition)
|
||||
|
||||
; Type annotations
|
||||
(parametrized_type_expression
|
||||
[
|
||||
(identifier) @type
|
||||
(field_expression
|
||||
(identifier) @type .)
|
||||
]
|
||||
(curly_expression
|
||||
(_) @type))
|
||||
|
||||
(typed_expression
|
||||
(identifier) @type .)
|
||||
|
||||
(unary_typed_expression
|
||||
(identifier) @type .)
|
||||
|
||||
(where_expression
|
||||
[
|
||||
(curly_expression
|
||||
(_) @type)
|
||||
(_) @type
|
||||
] .)
|
||||
|
||||
(unary_expression
|
||||
(operator) @operator
|
||||
(_) @type
|
||||
(#any-of? @operator "<:" ">:"))
|
||||
|
||||
(binary_expression
|
||||
(_) @type
|
||||
(operator) @operator
|
||||
(_) @type
|
||||
(#any-of? @operator "<:" ">:"))
|
||||
|
||||
; Built-in types
|
||||
; print.("\"", filter(name -> typeof(Base.eval(Core, name)) in [DataType, UnionAll], names(Core)), "\" ")
|
||||
((identifier) @type.builtin
|
||||
(#any-of? @type.builtin
|
||||
"AbstractArray" "AbstractChar" "AbstractFloat" "AbstractString" "Any" "ArgumentError" "Array"
|
||||
"AssertionError" "AtomicMemory" "AtomicMemoryRef" "Bool" "BoundsError" "Char"
|
||||
"ConcurrencyViolationError" "Cvoid" "DataType" "DenseArray" "DivideError" "DomainError"
|
||||
"ErrorException" "Exception" "Expr" "FieldError" "Float16" "Float32" "Float64" "Function"
|
||||
"GenericMemory" "GenericMemoryRef" "GlobalRef" "IO" "InexactError" "InitError" "Int" "Int128"
|
||||
"Int16" "Int32" "Int64" "Int8" "Integer" "InterruptException" "LineNumberNode" "LoadError"
|
||||
"Memory" "MemoryRef" "Method" "MethodError" "Module" "NTuple" "NamedTuple" "Nothing" "Number"
|
||||
"OutOfMemoryError" "OverflowError" "Pair" "Ptr" "QuoteNode" "ReadOnlyMemoryError" "Real" "Ref"
|
||||
"SegmentationFault" "Signed" "StackOverflowError" "String" "Symbol" "Task" "Tuple" "Type"
|
||||
"TypeError" "TypeVar" "UInt" "UInt128" "UInt16" "UInt32" "UInt64" "UInt8" "UndefInitializer"
|
||||
"UndefKeywordError" "UndefRefError" "UndefVarError" "Union" "UnionAll" "Unsigned" "VecElement"
|
||||
"WeakRef"))
|
||||
|
||||
; Keywords
|
||||
[
|
||||
"global"
|
||||
"local"
|
||||
] @keyword
|
||||
|
||||
(compound_statement
|
||||
[
|
||||
"begin"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(quote_statement
|
||||
[
|
||||
"quote"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(let_statement
|
||||
[
|
||||
"let"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(if_statement
|
||||
[
|
||||
"if"
|
||||
"end"
|
||||
] @keyword.conditional)
|
||||
|
||||
(elseif_clause
|
||||
"elseif" @keyword.conditional)
|
||||
|
||||
(else_clause
|
||||
"else" @keyword.conditional)
|
||||
|
||||
(ternary_expression
|
||||
[
|
||||
"?"
|
||||
":"
|
||||
] @keyword.conditional.ternary)
|
||||
|
||||
(try_statement
|
||||
[
|
||||
"try"
|
||||
"end"
|
||||
] @keyword.exception)
|
||||
|
||||
(catch_clause
|
||||
"catch" @keyword.exception)
|
||||
|
||||
(finally_clause
|
||||
"finally" @keyword.exception)
|
||||
|
||||
(for_statement
|
||||
[
|
||||
"for"
|
||||
"end"
|
||||
] @keyword.repeat)
|
||||
|
||||
(for_binding
|
||||
"outer" @keyword.repeat)
|
||||
|
||||
; comprehensions
|
||||
(for_clause
|
||||
"for" @keyword.repeat)
|
||||
|
||||
(if_clause
|
||||
"if" @keyword.conditional)
|
||||
|
||||
(while_statement
|
||||
[
|
||||
"while"
|
||||
"end"
|
||||
] @keyword.repeat)
|
||||
|
||||
[
|
||||
(break_statement)
|
||||
(continue_statement)
|
||||
] @keyword.repeat
|
||||
|
||||
[
|
||||
"const"
|
||||
"mutable"
|
||||
] @keyword.modifier
|
||||
|
||||
(function_definition
|
||||
[
|
||||
"function"
|
||||
"end"
|
||||
] @keyword.function)
|
||||
|
||||
(do_clause
|
||||
[
|
||||
"do"
|
||||
"end"
|
||||
] @keyword.function)
|
||||
|
||||
(macro_definition
|
||||
[
|
||||
"macro"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(return_statement
|
||||
"return" @keyword.return)
|
||||
|
||||
(module_definition
|
||||
[
|
||||
"module"
|
||||
"baremodule"
|
||||
"end"
|
||||
] @keyword.import)
|
||||
|
||||
(export_statement
|
||||
"export" @keyword.import)
|
||||
|
||||
(public_statement
|
||||
"public" @keyword.import)
|
||||
|
||||
(import_statement
|
||||
"import" @keyword.import)
|
||||
|
||||
(using_statement
|
||||
"using" @keyword.import)
|
||||
|
||||
(import_alias
|
||||
"as" @keyword.import)
|
||||
|
||||
(selected_import
|
||||
":" @punctuation.delimiter)
|
||||
|
||||
(struct_definition
|
||||
[
|
||||
"mutable"
|
||||
"struct"
|
||||
"end"
|
||||
] @keyword.type)
|
||||
|
||||
(abstract_definition
|
||||
[
|
||||
"abstract"
|
||||
"type"
|
||||
"end"
|
||||
] @keyword.type)
|
||||
|
||||
(primitive_definition
|
||||
[
|
||||
"primitive"
|
||||
"type"
|
||||
"end"
|
||||
] @keyword.type)
|
||||
|
||||
; Operators & Punctuation
|
||||
(operator) @operator
|
||||
|
||||
(adjoint_expression
|
||||
"'" @operator)
|
||||
|
||||
(range_expression
|
||||
":" @operator)
|
||||
|
||||
(arrow_function_expression
|
||||
"->" @operator)
|
||||
|
||||
[
|
||||
"."
|
||||
"..."
|
||||
] @punctuation.special
|
||||
|
||||
[
|
||||
","
|
||||
";"
|
||||
"::"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Treat `::` as operator in type contexts, see
|
||||
; https://github.com/nvim-treesitter/nvim-treesitter/pull/7392
|
||||
(typed_expression
|
||||
"::" @operator)
|
||||
|
||||
(unary_typed_expression
|
||||
"::" @operator)
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
; Interpolation
|
||||
(string_interpolation
|
||||
.
|
||||
"$" @punctuation.special)
|
||||
|
||||
(interpolation_expression
|
||||
.
|
||||
"$" @punctuation.special)
|
||||
|
||||
; Keyword operators
|
||||
((operator) @keyword.operator
|
||||
(#any-of? @keyword.operator "in" "isa"))
|
||||
|
||||
(where_expression
|
||||
"where" @keyword.operator)
|
||||
|
||||
; Built-in constants
|
||||
((identifier) @constant.builtin
|
||||
(#any-of? @constant.builtin "nothing" "missing"))
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#any-of? @variable.builtin "begin" "end")
|
||||
(#has-ancestor? @variable.builtin index_expression))
|
||||
|
||||
; Literals
|
||||
(boolean_literal) @boolean
|
||||
|
||||
(integer_literal) @number
|
||||
|
||||
(float_literal) @number.float
|
||||
|
||||
((identifier) @number.float
|
||||
(#any-of? @number.float "NaN" "NaN16" "NaN32" "Inf" "Inf16" "Inf32"))
|
||||
|
||||
(character_literal) @character
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(string_literal) @string
|
||||
|
||||
(prefixed_string_literal
|
||||
prefix: (identifier) @function.macro) @string
|
||||
|
||||
(command_literal) @string.special
|
||||
|
||||
(prefixed_command_literal
|
||||
prefix: (identifier) @function.macro) @string.special
|
||||
|
||||
((string_literal) @string.documentation
|
||||
.
|
||||
[
|
||||
(abstract_definition)
|
||||
(assignment)
|
||||
(const_statement)
|
||||
(function_definition)
|
||||
(macro_definition)
|
||||
(module_definition)
|
||||
(struct_definition)
|
||||
])
|
||||
|
||||
(source_file
|
||||
(string_literal) @string.documentation
|
||||
.
|
||||
[
|
||||
(identifier)
|
||||
(call_expression)
|
||||
])
|
||||
|
||||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment
|
||||
@@ -0,0 +1,158 @@
|
||||
; File autogenerated by build-flavored-queries.py; do not edit
|
||||
|
||||
; This file specifies how matched syntax patterns should be highlighted
|
||||
|
||||
[
|
||||
"export"
|
||||
"import"
|
||||
] @keyword.import
|
||||
|
||||
"mod" @module
|
||||
|
||||
[
|
||||
"alias"
|
||||
"set"
|
||||
"shell"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
] @keyword.conditional
|
||||
|
||||
; Variables
|
||||
|
||||
(value
|
||||
(identifier) @variable)
|
||||
|
||||
(alias
|
||||
left: (identifier) @variable)
|
||||
|
||||
(assignment
|
||||
left: (identifier) @variable)
|
||||
|
||||
; Functions
|
||||
|
||||
(recipe_header
|
||||
name: (identifier) @function)
|
||||
|
||||
(dependency
|
||||
name: (identifier) @function.call)
|
||||
|
||||
(dependency_expression
|
||||
name: (identifier) @function.call)
|
||||
|
||||
(function_call
|
||||
name: (identifier) @function.call)
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameter
|
||||
name: (identifier) @variable.parameter)
|
||||
|
||||
; Namespaces
|
||||
|
||||
(module
|
||||
name: (identifier) @module)
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
":="
|
||||
"?"
|
||||
"=="
|
||||
"!="
|
||||
"=~"
|
||||
"@"
|
||||
"="
|
||||
"$"
|
||||
"*"
|
||||
"+"
|
||||
"&&"
|
||||
"@-"
|
||||
"-@"
|
||||
"-"
|
||||
"/"
|
||||
":"
|
||||
] @operator
|
||||
|
||||
; Punctuation
|
||||
|
||||
"," @punctuation.delimiter
|
||||
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
"("
|
||||
")"
|
||||
"{{"
|
||||
"}}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[ "`" "```" ] @punctuation.special
|
||||
|
||||
; Literals
|
||||
|
||||
(boolean) @boolean
|
||||
|
||||
[
|
||||
(string)
|
||||
(external_command)
|
||||
] @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @spell @comment
|
||||
|
||||
(shebang) @keyword.directive
|
||||
|
||||
; highlight known settings (filtering does not always work)
|
||||
(setting
|
||||
left: (identifier) @keyword
|
||||
(#any-of? @keyword
|
||||
"allow-duplicate-recipes"
|
||||
"allow-duplicate-variables"
|
||||
"dotenv-filename"
|
||||
"dotenv-load"
|
||||
"dotenv-path"
|
||||
"dotenv-required"
|
||||
"export"
|
||||
"fallback"
|
||||
"ignore-comments"
|
||||
"positional-arguments"
|
||||
"shell"
|
||||
"shell-interpreter"
|
||||
"tempdir"
|
||||
"windows-powershell"
|
||||
"windows-shell"
|
||||
"working-directory"))
|
||||
|
||||
; highlight known attributes (filtering does not always work)
|
||||
(attribute
|
||||
(identifier) @attribute
|
||||
(#any-of? @attribute
|
||||
"confirm"
|
||||
"doc"
|
||||
"extension"
|
||||
"group"
|
||||
"linux"
|
||||
"macos"
|
||||
"metadata"
|
||||
"no-cd"
|
||||
"no-exit-message"
|
||||
"no-quiet"
|
||||
"openbsd"
|
||||
"parallel"
|
||||
"positional-arguments"
|
||||
"private"
|
||||
"script"
|
||||
"unix"
|
||||
"windows"
|
||||
"working-directory"))
|
||||
|
||||
; Numbers are part of the syntax tree, even if disallowed
|
||||
(numeric_error) @error
|
||||
@@ -0,0 +1,376 @@
|
||||
;; Based on the nvim-treesitter highlighting, which is under the Apache license.
|
||||
;; See https://github.com/nvim-treesitter/nvim-treesitter/blob/f8ab59861eed4a1c168505e3433462ed800f2bae/queries/kotlin/highlights.scm
|
||||
;;
|
||||
;; The only difference in this file is that queries using #lua-match?
|
||||
;; have been removed.
|
||||
|
||||
;;; Identifiers
|
||||
|
||||
(simple_identifier) @variable
|
||||
|
||||
; `it` keyword inside lambdas
|
||||
; FIXME: This will highlight the keyword outside of lambdas since tree-sitter
|
||||
; does not allow us to check for arbitrary nestation
|
||||
((simple_identifier) @variable.builtin
|
||||
(#eq? @variable.builtin "it"))
|
||||
|
||||
; `field` keyword inside property getter/setter
|
||||
; FIXME: This will highlight the keyword outside of getters and setters
|
||||
; since tree-sitter does not allow us to check for arbitrary nestation
|
||||
((simple_identifier) @variable.builtin
|
||||
(#eq? @variable.builtin "field"))
|
||||
|
||||
; `this` this keyword inside classes
|
||||
(this_expression) @variable.builtin
|
||||
|
||||
; `super` keyword inside classes
|
||||
(super_expression) @variable.builtin
|
||||
|
||||
(class_parameter
|
||||
(simple_identifier) @property)
|
||||
|
||||
(class_body
|
||||
(property_declaration
|
||||
(variable_declaration
|
||||
(simple_identifier) @property)))
|
||||
|
||||
; id_1.id_2.id_3: `id_2` and `id_3` are assumed as object properties
|
||||
(_
|
||||
(navigation_suffix
|
||||
(simple_identifier) @property))
|
||||
|
||||
(enum_entry
|
||||
(simple_identifier) @constant)
|
||||
|
||||
(type_identifier) @type
|
||||
|
||||
((type_identifier) @type.builtin
|
||||
(#any-of? @type.builtin
|
||||
"Byte"
|
||||
"Short"
|
||||
"Int"
|
||||
"Long"
|
||||
"UByte"
|
||||
"UShort"
|
||||
"UInt"
|
||||
"ULong"
|
||||
"Float"
|
||||
"Double"
|
||||
"Boolean"
|
||||
"Char"
|
||||
"String"
|
||||
"Array"
|
||||
"ByteArray"
|
||||
"ShortArray"
|
||||
"IntArray"
|
||||
"LongArray"
|
||||
"UByteArray"
|
||||
"UShortArray"
|
||||
"UIntArray"
|
||||
"ULongArray"
|
||||
"FloatArray"
|
||||
"DoubleArray"
|
||||
"BooleanArray"
|
||||
"CharArray"
|
||||
"Map"
|
||||
"Set"
|
||||
"List"
|
||||
"EmptyMap"
|
||||
"EmptySet"
|
||||
"EmptyList"
|
||||
"MutableMap"
|
||||
"MutableSet"
|
||||
"MutableList"
|
||||
))
|
||||
|
||||
(package_header
|
||||
. (identifier)) @namespace
|
||||
|
||||
(import_header
|
||||
"import" @include)
|
||||
|
||||
|
||||
; TODO: Seperate labeled returns/breaks/continue/super/this
|
||||
; Must be implemented in the parser first
|
||||
(label) @label
|
||||
|
||||
;;; Function definitions
|
||||
|
||||
(function_declaration
|
||||
. (simple_identifier) @function)
|
||||
|
||||
(getter
|
||||
("get") @function.builtin)
|
||||
(setter
|
||||
("set") @function.builtin)
|
||||
|
||||
(primary_constructor) @constructor
|
||||
(secondary_constructor
|
||||
("constructor") @constructor)
|
||||
|
||||
(constructor_invocation
|
||||
(user_type
|
||||
(type_identifier) @constructor))
|
||||
|
||||
(anonymous_initializer
|
||||
("init") @constructor)
|
||||
|
||||
(parameter
|
||||
(simple_identifier) @parameter)
|
||||
|
||||
(parameter_with_optional_type
|
||||
(simple_identifier) @parameter)
|
||||
|
||||
; lambda parameters
|
||||
(lambda_literal
|
||||
(lambda_parameters
|
||||
(variable_declaration
|
||||
(simple_identifier) @parameter)))
|
||||
|
||||
;;; Function calls
|
||||
|
||||
; function()
|
||||
(call_expression
|
||||
. (simple_identifier) @function)
|
||||
|
||||
; object.function() or object.property.function()
|
||||
(call_expression
|
||||
(navigation_expression
|
||||
(navigation_suffix
|
||||
(simple_identifier) @function) . ))
|
||||
|
||||
(call_expression
|
||||
. (simple_identifier) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"arrayOf"
|
||||
"arrayOfNulls"
|
||||
"byteArrayOf"
|
||||
"shortArrayOf"
|
||||
"intArrayOf"
|
||||
"longArrayOf"
|
||||
"ubyteArrayOf"
|
||||
"ushortArrayOf"
|
||||
"uintArrayOf"
|
||||
"ulongArrayOf"
|
||||
"floatArrayOf"
|
||||
"doubleArrayOf"
|
||||
"booleanArrayOf"
|
||||
"charArrayOf"
|
||||
"emptyArray"
|
||||
"mapOf"
|
||||
"setOf"
|
||||
"listOf"
|
||||
"emptyMap"
|
||||
"emptySet"
|
||||
"emptyList"
|
||||
"mutableMapOf"
|
||||
"mutableSetOf"
|
||||
"mutableListOf"
|
||||
"print"
|
||||
"println"
|
||||
"error"
|
||||
"TODO"
|
||||
"run"
|
||||
"runCatching"
|
||||
"repeat"
|
||||
"lazy"
|
||||
"lazyOf"
|
||||
"enumValues"
|
||||
"enumValueOf"
|
||||
"assert"
|
||||
"check"
|
||||
"checkNotNull"
|
||||
"require"
|
||||
"requireNotNull"
|
||||
"with"
|
||||
"synchronized"
|
||||
))
|
||||
|
||||
;;; Literals
|
||||
|
||||
[
|
||||
(line_comment)
|
||||
(multiline_comment)
|
||||
(shebang_line)
|
||||
] @comment
|
||||
|
||||
(real_literal) @float
|
||||
[
|
||||
(integer_literal)
|
||||
(long_literal)
|
||||
(hex_literal)
|
||||
(bin_literal)
|
||||
(unsigned_literal)
|
||||
] @number
|
||||
|
||||
[
|
||||
(null_literal) ; should be highlighted the same as booleans
|
||||
(boolean_literal)
|
||||
] @boolean
|
||||
|
||||
(character_literal) @character
|
||||
|
||||
(string_literal) @string
|
||||
|
||||
(character_escape_seq) @string.escape
|
||||
|
||||
; There are 3 ways to define a regex
|
||||
; - "[abc]?".toRegex()
|
||||
(call_expression
|
||||
(navigation_expression
|
||||
((string_literal) @string.regex)
|
||||
(navigation_suffix
|
||||
((simple_identifier) @_function
|
||||
(#eq? @_function "toRegex")))))
|
||||
|
||||
; - Regex("[abc]?")
|
||||
(call_expression
|
||||
((simple_identifier) @_function
|
||||
(#eq? @_function "Regex"))
|
||||
(call_suffix
|
||||
(value_arguments
|
||||
(value_argument
|
||||
(string_literal) @string.regex))))
|
||||
|
||||
; - Regex.fromLiteral("[abc]?")
|
||||
(call_expression
|
||||
(navigation_expression
|
||||
((simple_identifier) @_class
|
||||
(#eq? @_class "Regex"))
|
||||
(navigation_suffix
|
||||
((simple_identifier) @_function
|
||||
(#eq? @_function "fromLiteral"))))
|
||||
(call_suffix
|
||||
(value_arguments
|
||||
(value_argument
|
||||
(string_literal) @string.regex))))
|
||||
|
||||
;;; Keywords
|
||||
|
||||
(type_alias "typealias" @keyword)
|
||||
[
|
||||
(class_modifier)
|
||||
(member_modifier)
|
||||
(function_modifier)
|
||||
(property_modifier)
|
||||
(platform_modifier)
|
||||
(variance_modifier)
|
||||
(parameter_modifier)
|
||||
(visibility_modifier)
|
||||
(reification_modifier)
|
||||
(inheritance_modifier)
|
||||
]@keyword
|
||||
|
||||
[
|
||||
"val"
|
||||
"var"
|
||||
"enum"
|
||||
"class"
|
||||
"object"
|
||||
"interface"
|
||||
; "typeof" ; NOTE: It is reserved for future use
|
||||
] @keyword
|
||||
|
||||
("fun") @keyword.function
|
||||
|
||||
(jump_expression) @keyword.return
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"when"
|
||||
] @conditional
|
||||
|
||||
[
|
||||
"for"
|
||||
"do"
|
||||
"while"
|
||||
] @repeat
|
||||
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
"throw"
|
||||
"finally"
|
||||
] @exception
|
||||
|
||||
|
||||
(annotation
|
||||
"@" @attribute (use_site_target)? @attribute)
|
||||
(annotation
|
||||
(user_type
|
||||
(type_identifier) @attribute))
|
||||
(annotation
|
||||
(constructor_invocation
|
||||
(user_type
|
||||
(type_identifier) @attribute)))
|
||||
|
||||
(file_annotation
|
||||
"@" @attribute "file" @attribute ":" @attribute)
|
||||
(file_annotation
|
||||
(user_type
|
||||
(type_identifier) @attribute))
|
||||
(file_annotation
|
||||
(constructor_invocation
|
||||
(user_type
|
||||
(type_identifier) @attribute)))
|
||||
|
||||
;;; Operators & Punctuation
|
||||
|
||||
[
|
||||
"!"
|
||||
"!="
|
||||
"!=="
|
||||
"="
|
||||
"=="
|
||||
"==="
|
||||
">"
|
||||
">="
|
||||
"<"
|
||||
"<="
|
||||
"||"
|
||||
"&&"
|
||||
"+"
|
||||
"++"
|
||||
"+="
|
||||
"-"
|
||||
"--"
|
||||
"-="
|
||||
"*"
|
||||
"*="
|
||||
"/"
|
||||
"/="
|
||||
"%"
|
||||
"%="
|
||||
"?."
|
||||
"?:"
|
||||
"!!"
|
||||
"is"
|
||||
"in"
|
||||
"as"
|
||||
"as?"
|
||||
".."
|
||||
"..<"
|
||||
"->"
|
||||
] @operator
|
||||
|
||||
[
|
||||
"(" ")"
|
||||
"[" "]"
|
||||
"{" "}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"."
|
||||
","
|
||||
";"
|
||||
":"
|
||||
"::"
|
||||
] @punctuation.delimiter
|
||||
|
||||
; NOTE: `interpolated_identifier`s can be highlighted in any way
|
||||
(string_literal
|
||||
(interpolated_identifier) @none)
|
||||
(string_literal
|
||||
(interpolated_expression) @none
|
||||
"}" @punctuation.special)
|
||||
@@ -0,0 +1,204 @@
|
||||
; Keywords
|
||||
"return" @keyword.return
|
||||
|
||||
[
|
||||
"goto"
|
||||
"in"
|
||||
"local"
|
||||
"global"
|
||||
] @keyword
|
||||
|
||||
(label_statement) @label
|
||||
|
||||
(break_statement) @keyword
|
||||
|
||||
(do_statement
|
||||
[
|
||||
"do"
|
||||
"end"
|
||||
] @keyword)
|
||||
|
||||
(while_statement
|
||||
[
|
||||
"while"
|
||||
"do"
|
||||
"end"
|
||||
] @repeat)
|
||||
|
||||
(repeat_statement
|
||||
[
|
||||
"repeat"
|
||||
"until"
|
||||
] @repeat)
|
||||
|
||||
(if_statement
|
||||
[
|
||||
"if"
|
||||
"elseif"
|
||||
"else"
|
||||
"then"
|
||||
"end"
|
||||
] @conditional)
|
||||
|
||||
(elseif_statement
|
||||
[
|
||||
"elseif"
|
||||
"then"
|
||||
"end"
|
||||
] @conditional)
|
||||
|
||||
(else_statement
|
||||
[
|
||||
"else"
|
||||
"end"
|
||||
] @conditional)
|
||||
|
||||
(for_statement
|
||||
[
|
||||
"for"
|
||||
"do"
|
||||
"end"
|
||||
] @repeat)
|
||||
|
||||
(function_declaration
|
||||
[
|
||||
"function"
|
||||
"end"
|
||||
] @keyword.function)
|
||||
|
||||
(function_definition
|
||||
[
|
||||
"function"
|
||||
"end"
|
||||
] @keyword.function)
|
||||
|
||||
; Operators
|
||||
(binary_expression
|
||||
operator: _ @operator)
|
||||
|
||||
(unary_expression
|
||||
operator: _ @operator)
|
||||
|
||||
"=" @operator
|
||||
|
||||
[
|
||||
"and"
|
||||
"not"
|
||||
"or"
|
||||
] @keyword.operator
|
||||
|
||||
; Punctuations
|
||||
[
|
||||
";"
|
||||
":"
|
||||
","
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Brackets
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
; Variables
|
||||
(identifier) @variable
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#eq? @variable.builtin "self"))
|
||||
|
||||
(variable_list
|
||||
(attribute
|
||||
"<" @punctuation.bracket
|
||||
(identifier) @attribute
|
||||
">" @punctuation.bracket))
|
||||
|
||||
; Constants
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
||||
|
||||
(vararg_expression) @constant
|
||||
|
||||
(nil) @constant.builtin
|
||||
|
||||
[
|
||||
(false)
|
||||
(true)
|
||||
] @boolean
|
||||
|
||||
; Tables
|
||||
(field
|
||||
name: (identifier) @field)
|
||||
|
||||
(dot_index_expression
|
||||
field: (identifier) @field)
|
||||
|
||||
(table_constructor
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
] @constructor)
|
||||
|
||||
; Functions
|
||||
(parameters
|
||||
(identifier) @parameter)
|
||||
|
||||
(function_declaration
|
||||
name: [
|
||||
(identifier) @function
|
||||
(dot_index_expression
|
||||
field: (identifier) @function)
|
||||
])
|
||||
|
||||
(function_declaration
|
||||
name: (method_index_expression
|
||||
method: (identifier) @method))
|
||||
|
||||
(assignment_statement
|
||||
(variable_list
|
||||
.
|
||||
name: [
|
||||
(identifier) @function
|
||||
(dot_index_expression
|
||||
field: (identifier) @function)
|
||||
])
|
||||
(expression_list
|
||||
.
|
||||
value: (function_definition)))
|
||||
|
||||
(table_constructor
|
||||
(field
|
||||
name: (identifier) @function
|
||||
value: (function_definition)))
|
||||
|
||||
(function_call
|
||||
name: [
|
||||
(identifier) @function.call
|
||||
(dot_index_expression
|
||||
field: (identifier) @function.call)
|
||||
(method_index_expression
|
||||
method: (identifier) @method.call)
|
||||
])
|
||||
|
||||
(function_call
|
||||
(identifier) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
; built-in functions in Lua 5.1
|
||||
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile"
|
||||
"loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawset" "require"
|
||||
"select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall"))
|
||||
|
||||
; Others
|
||||
(comment) @comment
|
||||
|
||||
(hash_bang_line) @preproc
|
||||
|
||||
(number) @number
|
||||
|
||||
(string) @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
@@ -0,0 +1,171 @@
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
":"
|
||||
"&:"
|
||||
"::"
|
||||
"|"
|
||||
";"
|
||||
"\""
|
||||
"'"
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"$"
|
||||
"$$"
|
||||
] @punctuation.special
|
||||
|
||||
(automatic_variable
|
||||
[ "@" "%" "<" "?" "^" "+" "/" "*" "D" "F"] @punctuation.special)
|
||||
|
||||
(automatic_variable
|
||||
"/" @error . ["D" "F"])
|
||||
|
||||
[
|
||||
"="
|
||||
":="
|
||||
"::="
|
||||
"?="
|
||||
"+="
|
||||
"!="
|
||||
"@"
|
||||
"-"
|
||||
"+"
|
||||
] @operator
|
||||
|
||||
[
|
||||
(text)
|
||||
(string)
|
||||
(raw_text)
|
||||
] @string
|
||||
|
||||
(variable_assignment (word) @string)
|
||||
|
||||
[
|
||||
"ifeq"
|
||||
"ifneq"
|
||||
"ifdef"
|
||||
"ifndef"
|
||||
"else"
|
||||
"endif"
|
||||
"if"
|
||||
"or" ; boolean functions are conditional in make grammar
|
||||
"and"
|
||||
] @conditional
|
||||
|
||||
"foreach" @repeat
|
||||
|
||||
[
|
||||
"define"
|
||||
"endef"
|
||||
"vpath"
|
||||
"undefine"
|
||||
"export"
|
||||
"unexport"
|
||||
"override"
|
||||
"private"
|
||||
; "load"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"include"
|
||||
"sinclude"
|
||||
"-include"
|
||||
] @include
|
||||
|
||||
[
|
||||
"subst"
|
||||
"patsubst"
|
||||
"strip"
|
||||
"findstring"
|
||||
"filter"
|
||||
"filter-out"
|
||||
"sort"
|
||||
"word"
|
||||
"words"
|
||||
"wordlist"
|
||||
"firstword"
|
||||
"lastword"
|
||||
"dir"
|
||||
"notdir"
|
||||
"suffix"
|
||||
"basename"
|
||||
"addsuffix"
|
||||
"addprefix"
|
||||
"join"
|
||||
"wildcard"
|
||||
"realpath"
|
||||
"abspath"
|
||||
"call"
|
||||
"eval"
|
||||
"file"
|
||||
"value"
|
||||
"shell"
|
||||
] @keyword.function
|
||||
|
||||
[
|
||||
"error"
|
||||
"warning"
|
||||
"info"
|
||||
] @exception
|
||||
|
||||
;; Variable
|
||||
(variable_assignment
|
||||
name: (word) @constant)
|
||||
|
||||
(variable_reference
|
||||
(word) @constant)
|
||||
|
||||
(comment) @comment
|
||||
|
||||
((word) @clean @string.regex
|
||||
(#match? @clean "[%\*\?]"))
|
||||
|
||||
(function_call
|
||||
function: "error"
|
||||
(arguments (text) @text.danger))
|
||||
|
||||
(function_call
|
||||
function: "warning"
|
||||
(arguments (text) @text.warning))
|
||||
|
||||
(function_call
|
||||
function: "info"
|
||||
(arguments (text) @text.note))
|
||||
|
||||
;; Install Command Categories
|
||||
;; Others special variables
|
||||
;; Variables Used by Implicit Rules
|
||||
[
|
||||
"VPATH"
|
||||
".RECIPEPREFIX"
|
||||
] @constant.builtin
|
||||
|
||||
(variable_assignment
|
||||
name: (word) @clean @constant.builtin
|
||||
(#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS)$"))
|
||||
|
||||
(variable_reference
|
||||
(word) @clean @constant.builtin
|
||||
(#match? @clean "^(AR|AS|CC|CXX|CPP|FC|M2C|PC|CO|GET|LEX|YACC|LINT|MAKEINFO|TEX|TEXI2DVI|WEAVE|CWEAVE|TANGLE|CTANGLE|RM|ARFLAGS|ASFLAGS|CFLAGS|CXXFLAGS|COFLAGS|CPPFLAGS|FFLAGS|GFLAGS|LDFLAGS|LDLIBS|LFLAGS|YFLAGS|PFLAGS|RFLAGS|LINTFLAGS|PRE_INSTALL|POST_INSTALL|NORMAL_INSTALL|PRE_UNINSTALL|POST_UNINSTALL|NORMAL_UNINSTALL|MAKEFILE_LIST|MAKE_RESTARTS|MAKE_TERMOUT|MAKE_TERMERR|\.DEFAULT_GOAL|\.RECIPEPREFIX|\.EXTRA_PREREQS\.VARIABLES|\.FEATURES|\.INCLUDE_DIRS|\.LOADED)$"))
|
||||
|
||||
;; Standart targets
|
||||
(targets
|
||||
(word) @constant.macro
|
||||
(#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
|
||||
|
||||
(targets
|
||||
(word) @constant.macro
|
||||
(#match? @constant.macro "^(all|install|install-html|install-dvi|install-pdf|install-ps|uninstall|install-strip|clean|distclean|mostlyclean|maintainer-clean|TAGS|info|dvi|html|pdf|ps|dist|check|installcheck|installdirs)$"))
|
||||
|
||||
;; Builtin targets
|
||||
(targets
|
||||
(word) @constant.macro
|
||||
(#match? @constant.macro "^\.(PHONY|SUFFIXES|DEFAULT|PRECIOUS|INTERMEDIATE|SECONDARY|SECONDEXPANSION|DELETE_ON_ERROR|IGNORE|LOW_RESOLUTION_TIME|SILENT|EXPORT_ALL_VARIABLES|NOTPARALLEL|ONESHELL|POSIX)$"))
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
;From nvim-treesitter/nvim-treesitter
|
||||
(atx_heading
|
||||
(inline) @text.title)
|
||||
|
||||
(setext_heading
|
||||
(paragraph) @text.title)
|
||||
|
||||
[
|
||||
(atx_h1_marker)
|
||||
(atx_h2_marker)
|
||||
(atx_h3_marker)
|
||||
(atx_h4_marker)
|
||||
(atx_h5_marker)
|
||||
(atx_h6_marker)
|
||||
(setext_h1_underline)
|
||||
(setext_h2_underline)
|
||||
] @punctuation.special
|
||||
|
||||
[
|
||||
(link_title)
|
||||
(indented_code_block)
|
||||
(fenced_code_block)
|
||||
] @text.literal
|
||||
|
||||
(fenced_code_block_delimiter) @punctuation.delimiter
|
||||
|
||||
(code_fence_content) @none
|
||||
|
||||
(link_destination) @text.uri
|
||||
|
||||
(link_label) @text.reference
|
||||
|
||||
[
|
||||
(list_marker_plus)
|
||||
(list_marker_minus)
|
||||
(list_marker_star)
|
||||
(list_marker_dot)
|
||||
(list_marker_parenthesis)
|
||||
(thematic_break)
|
||||
] @punctuation.special
|
||||
|
||||
[
|
||||
(block_continuation)
|
||||
(block_quote_marker)
|
||||
] @punctuation.special
|
||||
|
||||
(backslash_escape) @string.escape
|
||||
@@ -0,0 +1,106 @@
|
||||
(comment) @comment @spell
|
||||
(annot_atom doc: (static_string) @spell)
|
||||
|
||||
[
|
||||
"forall"
|
||||
"in"
|
||||
"let"
|
||||
"default"
|
||||
"doc"
|
||||
"rec"
|
||||
"optional"
|
||||
"priority"
|
||||
"force"
|
||||
"not_exported"
|
||||
] @keyword
|
||||
|
||||
"fun" @keyword.function
|
||||
|
||||
"import" @include
|
||||
|
||||
[ "if" "then" "else" ] @keyword.conditional
|
||||
"match" @keyword.conditional
|
||||
|
||||
(types) @type
|
||||
"Array" @type.builtin
|
||||
|
||||
; BUILTIN Constants
|
||||
(bool) @boolean
|
||||
"null" @constant.builtin
|
||||
(enum_tag) @constant
|
||||
|
||||
|
||||
(num_literal) @number
|
||||
[
|
||||
(infix_op)
|
||||
"|>"
|
||||
"="
|
||||
"&"
|
||||
"=="
|
||||
"/"
|
||||
"!="
|
||||
"<"
|
||||
">"
|
||||
] @operator
|
||||
|
||||
(type_atom) @type
|
||||
|
||||
(chunk_literal_single) @string
|
||||
(chunk_literal_multi) @string
|
||||
|
||||
(str_esc_char) @string.escape
|
||||
|
||||
[
|
||||
"{" "}"
|
||||
"(" ")"
|
||||
"[|" "|]"
|
||||
"[" "]"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
","
|
||||
"."
|
||||
":"
|
||||
"|"
|
||||
"->"
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
] @punctuation.delimiter
|
||||
|
||||
(multstr_start) @punctuation.bracket
|
||||
(multstr_end) @punctuation.bracket
|
||||
(interpolation_start) @punctuation.special
|
||||
(interpolation_end) @punctuation.special
|
||||
|
||||
|
||||
(builtin) @function.builtin
|
||||
|
||||
(fun_expr
|
||||
(pattern_fun
|
||||
(ident) @parameter
|
||||
)
|
||||
)
|
||||
|
||||
; application where the head terms is an identifier: function arg1 arg2 arg3
|
||||
(applicative t1:
|
||||
(applicative . (record_operand (atom (ident))) @function)
|
||||
)
|
||||
|
||||
; application where the head terms is a record field path: foo.bar.function arg1 arg2 arg3
|
||||
(applicative t1:
|
||||
(applicative . (record_operand (record_operation_chain)) @function)
|
||||
)
|
||||
(str_chunks) @string
|
||||
|
||||
(_
|
||||
(interpolation_start)
|
||||
(term) @string.special
|
||||
)
|
||||
|
||||
(field_path_elem) @property
|
||||
|
||||
(infix_expr
|
||||
op: (infix_b_op_6)
|
||||
t2: (infix_expr (applicative . (record_operand (record_operation_chain) @function )))
|
||||
)
|
||||
@@ -0,0 +1,99 @@
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
"if"
|
||||
"then"
|
||||
"else"
|
||||
"let"
|
||||
"inherit"
|
||||
"in"
|
||||
"rec"
|
||||
"with"
|
||||
"assert"
|
||||
"or"
|
||||
] @keyword
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin "^(__currentSystem|__currentTime|__langVersion|__nixPath|__nixVersion|__storeDir|builtins|false|null|true)$")
|
||||
(#is-not? local))
|
||||
|
||||
((identifier) @function.builtin
|
||||
(#match? @function.builtin "^(__add|__addErrorContext|__all|__any|__appendContext|__attrNames|__attrValues|__bitAnd|__bitOr|__bitXor|__catAttrs|__ceil|__compareVersions|__concatLists|__concatMap|__concatStringsSep|__deepSeq|__div|__elem|__elemAt|__fetchurl|__filter|__filterSource|__findFile|__flakeRefToString|__floor|__foldl'|__fromJSON|__functionArgs|__genList|__genericClosure|__getAttr|__getContext|__getEnv|__getFlake|__groupBy|__hasAttr|__hasContext|__hashFile|__hashString|__head|__intersectAttrs|__isAttrs|__isBool|__isFloat|__isFunction|__isInt|__isList|__isPath|__isString|__length|__lessThan|__listToAttrs|__mapAttrs|__match|__mul|__parseDrvName|__parseFlakeRef|__partition|__path|__pathExists|__readDir|__readFile|__readFileType|__replaceStrings|__seq|__sort|__split|__splitVersion|__storePath|__stringLength|__sub|__substring|__tail|__toFile|__toJSON|__toPath|__toXML|__trace|__traceVerbose|__tryEval|__typeOf|__unsafeDiscardOutputDependency|__unsafeDiscardStringContext|__unsafeGetAttrPos|__zipAttrsWith|abort|baseNameOf|break|derivation|derivationStrict|dirOf|fetchGit|fetchMercurial|fetchTarball|fetchTree|fromTOML|import|isNull|map|placeholder|removeAttrs|scopedImport|throw|toString)$")
|
||||
(#is-not? local))
|
||||
|
||||
[
|
||||
(integer_expression)
|
||||
(float_expression)
|
||||
] @number
|
||||
|
||||
(escape_sequence) @escape
|
||||
(dollar_escape) @escape
|
||||
|
||||
(function_expression
|
||||
universal: (identifier) @variable.parameter
|
||||
)
|
||||
|
||||
(formal
|
||||
name: (identifier) @variable.parameter
|
||||
"?"? @punctuation.delimiter)
|
||||
|
||||
(select_expression
|
||||
attrpath: (attrpath (identifier)) @property)
|
||||
|
||||
(apply_expression
|
||||
function: [
|
||||
(variable_expression (identifier)) @function
|
||||
(select_expression
|
||||
attrpath: (attrpath
|
||||
attr: (identifier) @function .))])
|
||||
|
||||
(unary_expression
|
||||
operator: _ @operator)
|
||||
|
||||
(binary_expression
|
||||
operator: _ @operator)
|
||||
|
||||
(variable_expression (identifier) @variable)
|
||||
|
||||
(binding
|
||||
attrpath: (attrpath (identifier)) @property)
|
||||
|
||||
(identifier) @property
|
||||
|
||||
(inherit_from attrs: (inherited_attrs attr: (identifier) @property) )
|
||||
|
||||
[
|
||||
";"
|
||||
"."
|
||||
","
|
||||
"="
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
[
|
||||
(string_expression)
|
||||
(indented_string_expression)
|
||||
] @string
|
||||
|
||||
[
|
||||
(path_expression)
|
||||
(hpath_expression)
|
||||
(spath_expression)
|
||||
] @string.special.path
|
||||
|
||||
(uri_expression) @string.special.uri
|
||||
|
||||
(interpolation
|
||||
"${" @punctuation.special
|
||||
(_) @embedded
|
||||
"}" @punctuation.special)
|
||||
@@ -0,0 +1,203 @@
|
||||
[
|
||||
(php_tag)
|
||||
(php_end_tag)
|
||||
] @tag
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
"and"
|
||||
"as"
|
||||
"break"
|
||||
"case"
|
||||
"catch"
|
||||
"class"
|
||||
"clone"
|
||||
"const"
|
||||
"continue"
|
||||
"declare"
|
||||
"default"
|
||||
"do"
|
||||
"echo"
|
||||
"else"
|
||||
"elseif"
|
||||
"enddeclare"
|
||||
"endfor"
|
||||
"endforeach"
|
||||
"endif"
|
||||
"endswitch"
|
||||
"endwhile"
|
||||
"enum"
|
||||
"exit"
|
||||
"extends"
|
||||
"finally"
|
||||
"fn"
|
||||
"for"
|
||||
"foreach"
|
||||
"function"
|
||||
"global"
|
||||
"goto"
|
||||
"if"
|
||||
"implements"
|
||||
"include"
|
||||
"include_once"
|
||||
"instanceof"
|
||||
"insteadof"
|
||||
"interface"
|
||||
"match"
|
||||
"namespace"
|
||||
"new"
|
||||
"or"
|
||||
"print"
|
||||
"require"
|
||||
"require_once"
|
||||
"return"
|
||||
"switch"
|
||||
"throw"
|
||||
"trait"
|
||||
"try"
|
||||
"use"
|
||||
"while"
|
||||
"xor"
|
||||
"yield"
|
||||
"yield from"
|
||||
(abstract_modifier)
|
||||
(final_modifier)
|
||||
(readonly_modifier)
|
||||
(static_modifier)
|
||||
(visibility_modifier)
|
||||
] @keyword
|
||||
|
||||
(function_static_declaration "static" @keyword)
|
||||
|
||||
; Namespace
|
||||
|
||||
(namespace_definition
|
||||
name: (namespace_name
|
||||
(name) @module))
|
||||
|
||||
(namespace_name
|
||||
(name) @module)
|
||||
|
||||
(namespace_use_clause
|
||||
[
|
||||
(name) @type
|
||||
(qualified_name
|
||||
(name) @type)
|
||||
alias: (name) @type
|
||||
])
|
||||
|
||||
(namespace_use_clause
|
||||
type: "function"
|
||||
[
|
||||
(name) @function
|
||||
(qualified_name
|
||||
(name) @function)
|
||||
alias: (name) @function
|
||||
])
|
||||
|
||||
(namespace_use_clause
|
||||
type: "const"
|
||||
[
|
||||
(name) @constant
|
||||
(qualified_name
|
||||
(name) @constant)
|
||||
alias: (name) @constant
|
||||
])
|
||||
|
||||
(relative_name "namespace" @module.builtin)
|
||||
|
||||
; Variables
|
||||
|
||||
(relative_scope) @variable.builtin
|
||||
|
||||
(variable_name) @variable
|
||||
|
||||
(method_declaration name: (name) @constructor
|
||||
(#eq? @constructor "__construct"))
|
||||
|
||||
(object_creation_expression [
|
||||
(name) @constructor
|
||||
(qualified_name (name) @constructor)
|
||||
(relative_name (name) @constructor)
|
||||
])
|
||||
|
||||
((name) @constant
|
||||
(#match? @constant "^_?[A-Z][A-Z\\d_]+$"))
|
||||
((name) @constant.builtin
|
||||
(#match? @constant.builtin "^__[A-Z][A-Z\d_]+__$"))
|
||||
(const_declaration (const_element (name) @constant))
|
||||
|
||||
; Types
|
||||
|
||||
(primitive_type) @type.builtin
|
||||
(cast_type) @type.builtin
|
||||
(named_type [
|
||||
(name) @type
|
||||
(qualified_name (name) @type)
|
||||
(relative_name (name) @type)
|
||||
]) @type
|
||||
(named_type (name) @type.builtin
|
||||
(#any-of? @type.builtin "static" "self"))
|
||||
|
||||
(scoped_call_expression
|
||||
scope: [
|
||||
(name) @type
|
||||
(qualified_name (name) @type)
|
||||
(relative_name (name) @type)
|
||||
])
|
||||
|
||||
; Functions
|
||||
|
||||
(array_creation_expression "array" @function.builtin)
|
||||
(list_literal "list" @function.builtin)
|
||||
(exit_statement "exit" @function.builtin "(")
|
||||
|
||||
(method_declaration
|
||||
name: (name) @function.method)
|
||||
|
||||
(function_call_expression
|
||||
function: [
|
||||
(qualified_name (name))
|
||||
(relative_name (name))
|
||||
(name)
|
||||
] @function)
|
||||
|
||||
(scoped_call_expression
|
||||
name: (name) @function)
|
||||
|
||||
(member_call_expression
|
||||
name: (name) @function.method)
|
||||
|
||||
(function_definition
|
||||
name: (name) @function)
|
||||
|
||||
; Member
|
||||
|
||||
(property_element
|
||||
(variable_name) @property)
|
||||
|
||||
(member_access_expression
|
||||
name: (variable_name (name)) @property)
|
||||
(member_access_expression
|
||||
name: (name) @property)
|
||||
|
||||
; Basic tokens
|
||||
[
|
||||
(string)
|
||||
(string_content)
|
||||
(encapsed_string)
|
||||
(heredoc)
|
||||
(heredoc_body)
|
||||
(nowdoc_body)
|
||||
] @string
|
||||
(boolean) @constant.builtin
|
||||
(null) @constant.builtin
|
||||
(integer) @number
|
||||
(float) @number
|
||||
(comment) @comment
|
||||
|
||||
((name) @variable.builtin
|
||||
(#eq? @variable.builtin "this"))
|
||||
|
||||
"$" @operator
|
||||
@@ -0,0 +1,48 @@
|
||||
[
|
||||
"syntax"
|
||||
"package"
|
||||
"option"
|
||||
"import"
|
||||
"service"
|
||||
"rpc"
|
||||
"returns"
|
||||
"message"
|
||||
"enum"
|
||||
"oneof"
|
||||
"repeated"
|
||||
"reserved"
|
||||
"to"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
(key_type)
|
||||
(type)
|
||||
(message_name)
|
||||
(enum_name)
|
||||
(service_name)
|
||||
(rpc_name)
|
||||
]@type
|
||||
|
||||
(string) @string
|
||||
|
||||
[
|
||||
(int_lit)
|
||||
(float_lit)
|
||||
] @number
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
; Identifier naming conventions
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
((identifier) @constructor
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z_]*$"))
|
||||
|
||||
; Function calls
|
||||
|
||||
(decorator) @function
|
||||
(decorator
|
||||
(identifier) @function)
|
||||
|
||||
(call
|
||||
function: (attribute attribute: (identifier) @function.method))
|
||||
(call
|
||||
function: (identifier) @function)
|
||||
|
||||
; Builtin functions
|
||||
|
||||
((call
|
||||
function: (identifier) @function.builtin)
|
||||
(#match?
|
||||
@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__)$"))
|
||||
|
||||
; Function definitions
|
||||
|
||||
(function_definition
|
||||
name: (identifier) @function)
|
||||
|
||||
(attribute attribute: (identifier) @property)
|
||||
(type (identifier) @type)
|
||||
|
||||
; Literals
|
||||
|
||||
[
|
||||
(none)
|
||||
(true)
|
||||
(false)
|
||||
] @constant.builtin
|
||||
|
||||
[
|
||||
(integer)
|
||||
(float)
|
||||
] @number
|
||||
|
||||
(comment) @comment
|
||||
(string) @string
|
||||
(escape_sequence) @escape
|
||||
|
||||
(interpolation
|
||||
"{" @punctuation.special
|
||||
"}" @punctuation.special) @embedded
|
||||
|
||||
[
|
||||
"-"
|
||||
"-="
|
||||
"!="
|
||||
"*"
|
||||
"**"
|
||||
"**="
|
||||
"*="
|
||||
"/"
|
||||
"//"
|
||||
"//="
|
||||
"/="
|
||||
"&"
|
||||
"&="
|
||||
"%"
|
||||
"%="
|
||||
"^"
|
||||
"^="
|
||||
"+"
|
||||
"->"
|
||||
"+="
|
||||
"<"
|
||||
"<<"
|
||||
"<<="
|
||||
"<="
|
||||
"<>"
|
||||
"="
|
||||
":="
|
||||
"=="
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
">>="
|
||||
"|"
|
||||
"|="
|
||||
"~"
|
||||
"@="
|
||||
"and"
|
||||
"in"
|
||||
"is"
|
||||
"not"
|
||||
"or"
|
||||
"is not"
|
||||
"not in"
|
||||
] @operator
|
||||
|
||||
[
|
||||
"as"
|
||||
"assert"
|
||||
"async"
|
||||
"await"
|
||||
"break"
|
||||
"class"
|
||||
"continue"
|
||||
"def"
|
||||
"del"
|
||||
"elif"
|
||||
"else"
|
||||
"except"
|
||||
"exec"
|
||||
"finally"
|
||||
"for"
|
||||
"from"
|
||||
"global"
|
||||
"if"
|
||||
"import"
|
||||
"lambda"
|
||||
"nonlocal"
|
||||
"pass"
|
||||
"print"
|
||||
"raise"
|
||||
"return"
|
||||
"try"
|
||||
"while"
|
||||
"with"
|
||||
"yield"
|
||||
"match"
|
||||
"case"
|
||||
] @keyword
|
||||
@@ -0,0 +1,112 @@
|
||||
; highlights.scm
|
||||
|
||||
; Literals
|
||||
|
||||
(integer) @number
|
||||
(float) @number
|
||||
(complex) @number
|
||||
|
||||
(string) @string
|
||||
(string (string_content (escape_sequence) @string.escape))
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"?" ":=" "=" "<-" "<<-" "->" "->>"
|
||||
"~" "|>" "||" "|" "&&" "&"
|
||||
"<" "<=" ">" ">=" "==" "!="
|
||||
"+" "-" "*" "/" "::" ":::"
|
||||
"**" "^" "$" "@" ":" "!"
|
||||
"special"
|
||||
] @operator
|
||||
|
||||
; Punctuation
|
||||
|
||||
[
|
||||
"(" ")"
|
||||
"{" "}"
|
||||
"[" "]"
|
||||
"[[" "]]"
|
||||
] @punctuation.bracket
|
||||
|
||||
(comma) @punctuation.delimiter
|
||||
|
||||
; Variables
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
; Functions
|
||||
|
||||
(binary_operator
|
||||
lhs: (identifier) @function
|
||||
operator: "<-"
|
||||
rhs: (function_definition)
|
||||
)
|
||||
|
||||
(binary_operator
|
||||
lhs: (identifier) @function
|
||||
operator: "="
|
||||
rhs: (function_definition)
|
||||
)
|
||||
|
||||
; Calls
|
||||
|
||||
(call function: (identifier) @function)
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameters (parameter name: (identifier) @variable.parameter))
|
||||
(arguments (argument name: (identifier) @variable.parameter))
|
||||
|
||||
; Namespace
|
||||
|
||||
(namespace_operator lhs: (identifier) @namespace)
|
||||
|
||||
(call
|
||||
function: (namespace_operator rhs: (identifier) @function)
|
||||
)
|
||||
|
||||
; Keywords
|
||||
|
||||
(function_definition name: "function" @keyword.function)
|
||||
(function_definition name: "\\" @operator)
|
||||
|
||||
[
|
||||
"in"
|
||||
(return)
|
||||
(next)
|
||||
(break)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
] @conditional
|
||||
|
||||
[
|
||||
"while"
|
||||
"repeat"
|
||||
"for"
|
||||
] @repeat
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
[
|
||||
(null)
|
||||
(inf)
|
||||
(nan)
|
||||
(na)
|
||||
(dots)
|
||||
(dot_dot_i)
|
||||
] @constant.builtin
|
||||
|
||||
; Error
|
||||
|
||||
(ERROR) @error
|
||||
@@ -0,0 +1,63 @@
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"(?"
|
||||
"(?:"
|
||||
"(?<"
|
||||
"(?P<"
|
||||
"(?P="
|
||||
">"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"[:"
|
||||
":]"
|
||||
] @punctuation.bracket
|
||||
|
||||
(group_name) @property
|
||||
|
||||
[
|
||||
(identity_escape)
|
||||
(control_letter_escape)
|
||||
(character_class_escape)
|
||||
(control_escape)
|
||||
(start_assertion)
|
||||
(end_assertion)
|
||||
(boundary_assertion)
|
||||
(non_boundary_assertion)
|
||||
] @escape
|
||||
|
||||
[
|
||||
"*"
|
||||
"+"
|
||||
"?"
|
||||
"|"
|
||||
"="
|
||||
"!"
|
||||
] @operator
|
||||
|
||||
(count_quantifier
|
||||
[
|
||||
(decimal_digits) @number
|
||||
"," @punctuation.delimiter
|
||||
])
|
||||
|
||||
(inline_flags_group
|
||||
"-"? @operator
|
||||
":"? @punctuation.delimiter)
|
||||
|
||||
(flags) @character.special
|
||||
|
||||
(character_class
|
||||
[
|
||||
"^" @operator
|
||||
(class_range "-" @operator)
|
||||
])
|
||||
|
||||
[
|
||||
(class_character)
|
||||
(posix_class_name)
|
||||
] @constant.character
|
||||
|
||||
(pattern_character) @string
|
||||
@@ -0,0 +1,154 @@
|
||||
(identifier) @variable
|
||||
|
||||
((identifier) @function.method
|
||||
(#is-not? local))
|
||||
|
||||
[
|
||||
"alias"
|
||||
"and"
|
||||
"begin"
|
||||
"break"
|
||||
"case"
|
||||
"class"
|
||||
"def"
|
||||
"do"
|
||||
"else"
|
||||
"elsif"
|
||||
"end"
|
||||
"ensure"
|
||||
"for"
|
||||
"if"
|
||||
"in"
|
||||
"module"
|
||||
"next"
|
||||
"or"
|
||||
"rescue"
|
||||
"retry"
|
||||
"return"
|
||||
"then"
|
||||
"unless"
|
||||
"until"
|
||||
"when"
|
||||
"while"
|
||||
"yield"
|
||||
] @keyword
|
||||
|
||||
((identifier) @keyword
|
||||
(#match? @keyword "^(private|protected|public)$"))
|
||||
|
||||
(constant) @constructor
|
||||
|
||||
; Function calls
|
||||
|
||||
"defined?" @function.method.builtin
|
||||
|
||||
(call
|
||||
method: [(identifier) (constant)] @function.method)
|
||||
|
||||
((identifier) @function.method.builtin
|
||||
(#eq? @function.method.builtin "require"))
|
||||
|
||||
; Function definitions
|
||||
|
||||
(alias (identifier) @function.method)
|
||||
(setter (identifier) @function.method)
|
||||
(method name: [(identifier) (constant)] @function.method)
|
||||
(singleton_method name: [(identifier) (constant)] @function.method)
|
||||
|
||||
; Identifiers
|
||||
|
||||
[
|
||||
(class_variable)
|
||||
(instance_variable)
|
||||
] @property
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
|
||||
|
||||
(file) @constant.builtin
|
||||
(line) @constant.builtin
|
||||
(encoding) @constant.builtin
|
||||
|
||||
(hash_splat_nil
|
||||
"**" @operator) @constant.builtin
|
||||
|
||||
((constant) @constant
|
||||
(#match? @constant "^[A-Z\\d_]+$"))
|
||||
|
||||
[
|
||||
(self)
|
||||
(super)
|
||||
] @variable.builtin
|
||||
|
||||
(block_parameter (identifier) @variable.parameter)
|
||||
(block_parameters (identifier) @variable.parameter)
|
||||
(destructured_parameter (identifier) @variable.parameter)
|
||||
(hash_splat_parameter (identifier) @variable.parameter)
|
||||
(lambda_parameters (identifier) @variable.parameter)
|
||||
(method_parameters (identifier) @variable.parameter)
|
||||
(splat_parameter (identifier) @variable.parameter)
|
||||
|
||||
(keyword_parameter name: (identifier) @variable.parameter)
|
||||
(optional_parameter name: (identifier) @variable.parameter)
|
||||
|
||||
; Literals
|
||||
|
||||
[
|
||||
(string)
|
||||
(bare_string)
|
||||
(subshell)
|
||||
(heredoc_body)
|
||||
(heredoc_beginning)
|
||||
] @string
|
||||
|
||||
[
|
||||
(simple_symbol)
|
||||
(delimited_symbol)
|
||||
(hash_key_symbol)
|
||||
(bare_symbol)
|
||||
] @string.special.symbol
|
||||
|
||||
(regex) @string.special.regex
|
||||
(escape_sequence) @escape
|
||||
|
||||
[
|
||||
(integer)
|
||||
(float)
|
||||
] @number
|
||||
|
||||
[
|
||||
(nil)
|
||||
(true)
|
||||
(false)
|
||||
] @constant.builtin
|
||||
|
||||
(interpolation
|
||||
"#{" @punctuation.special
|
||||
"}" @punctuation.special) @embedded
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"="
|
||||
"=>"
|
||||
"->"
|
||||
] @operator
|
||||
|
||||
[
|
||||
","
|
||||
";"
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"%w("
|
||||
"%i("
|
||||
] @punctuation.bracket
|
||||
@@ -0,0 +1,161 @@
|
||||
; Identifiers
|
||||
|
||||
(type_identifier) @type
|
||||
(primitive_type) @type.builtin
|
||||
(field_identifier) @property
|
||||
|
||||
; Identifier conventions
|
||||
|
||||
; Assume all-caps names are constants
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z\\d_]+$'"))
|
||||
|
||||
; Assume uppercase names are enum constructors
|
||||
((identifier) @constructor
|
||||
(#match? @constructor "^[A-Z]"))
|
||||
|
||||
; Assume that uppercase names in paths are types
|
||||
((scoped_identifier
|
||||
path: (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
((scoped_identifier
|
||||
path: (scoped_identifier
|
||||
name: (identifier) @type))
|
||||
(#match? @type "^[A-Z]"))
|
||||
((scoped_type_identifier
|
||||
path: (identifier) @type)
|
||||
(#match? @type "^[A-Z]"))
|
||||
((scoped_type_identifier
|
||||
path: (scoped_identifier
|
||||
name: (identifier) @type))
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
; Assume all qualified names in struct patterns are enum constructors. (They're
|
||||
; either that, or struct names; highlighting both as constructors seems to be
|
||||
; the less glaring choice of error, visually.)
|
||||
(struct_pattern
|
||||
type: (scoped_type_identifier
|
||||
name: (type_identifier) @constructor))
|
||||
|
||||
; Function calls
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function)
|
||||
(call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function.method))
|
||||
(call_expression
|
||||
function: (scoped_identifier
|
||||
"::"
|
||||
name: (identifier) @function))
|
||||
|
||||
(generic_function
|
||||
function: (identifier) @function)
|
||||
(generic_function
|
||||
function: (scoped_identifier
|
||||
name: (identifier) @function))
|
||||
(generic_function
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function.method))
|
||||
|
||||
(macro_invocation
|
||||
macro: (identifier) @function.macro
|
||||
"!" @function.macro)
|
||||
|
||||
; Function definitions
|
||||
|
||||
(function_item (identifier) @function)
|
||||
(function_signature_item (identifier) @function)
|
||||
|
||||
(line_comment) @comment
|
||||
(block_comment) @comment
|
||||
|
||||
(line_comment (doc_comment)) @comment.documentation
|
||||
(block_comment (doc_comment)) @comment.documentation
|
||||
|
||||
"(" @punctuation.bracket
|
||||
")" @punctuation.bracket
|
||||
"[" @punctuation.bracket
|
||||
"]" @punctuation.bracket
|
||||
"{" @punctuation.bracket
|
||||
"}" @punctuation.bracket
|
||||
|
||||
(type_arguments
|
||||
"<" @punctuation.bracket
|
||||
">" @punctuation.bracket)
|
||||
(type_parameters
|
||||
"<" @punctuation.bracket
|
||||
">" @punctuation.bracket)
|
||||
|
||||
"::" @punctuation.delimiter
|
||||
":" @punctuation.delimiter
|
||||
"." @punctuation.delimiter
|
||||
"," @punctuation.delimiter
|
||||
";" @punctuation.delimiter
|
||||
|
||||
(parameter (identifier) @variable.parameter)
|
||||
|
||||
(lifetime (identifier) @label)
|
||||
|
||||
"as" @keyword
|
||||
"async" @keyword
|
||||
"await" @keyword
|
||||
"break" @keyword
|
||||
"const" @keyword
|
||||
"continue" @keyword
|
||||
"default" @keyword
|
||||
"dyn" @keyword
|
||||
"else" @keyword
|
||||
"enum" @keyword
|
||||
"extern" @keyword
|
||||
"fn" @keyword
|
||||
"for" @keyword
|
||||
"gen" @keyword
|
||||
"if" @keyword
|
||||
"impl" @keyword
|
||||
"in" @keyword
|
||||
"let" @keyword
|
||||
"loop" @keyword
|
||||
"macro_rules!" @keyword
|
||||
"match" @keyword
|
||||
"mod" @keyword
|
||||
"move" @keyword
|
||||
"pub" @keyword
|
||||
"raw" @keyword
|
||||
"ref" @keyword
|
||||
"return" @keyword
|
||||
"static" @keyword
|
||||
"struct" @keyword
|
||||
"trait" @keyword
|
||||
"type" @keyword
|
||||
"union" @keyword
|
||||
"unsafe" @keyword
|
||||
"use" @keyword
|
||||
"where" @keyword
|
||||
"while" @keyword
|
||||
"yield" @keyword
|
||||
(crate) @keyword
|
||||
(mutable_specifier) @keyword
|
||||
(use_list (self) @keyword)
|
||||
(scoped_use_list (self) @keyword)
|
||||
(scoped_identifier (self) @keyword)
|
||||
(super) @keyword
|
||||
|
||||
(self) @variable.builtin
|
||||
|
||||
(char_literal) @string
|
||||
(string_literal) @string
|
||||
(raw_string_literal) @string
|
||||
|
||||
(boolean_literal) @constant.builtin
|
||||
(integer_literal) @constant.builtin
|
||||
(float_literal) @constant.builtin
|
||||
|
||||
(escape_sequence) @escape
|
||||
|
||||
(attribute_item) @attribute
|
||||
(inner_attribute_item) @attribute
|
||||
|
||||
"*" @operator
|
||||
"&" @operator
|
||||
"'" @operator
|
||||
@@ -0,0 +1,179 @@
|
||||
;;;
|
||||
|
||||
";" @punctuation.delimiter
|
||||
"," @punctuation.delimiter
|
||||
"." @punctuation.delimiter
|
||||
|
||||
"(" @punctuation.bracket
|
||||
")" @punctuation.bracket
|
||||
|
||||
[
|
||||
"||"
|
||||
"~" "&" "|" "<<" ">>"
|
||||
"+" "-" "*" "/" "%"
|
||||
"=" "==" "!=" "<>" ">" ">=" "<" "<="
|
||||
"->" "->>"
|
||||
] @operator
|
||||
|
||||
;;;
|
||||
|
||||
(signed_number) @number
|
||||
|
||||
(numeric_literal) @number
|
||||
(string_literal) @string
|
||||
(blob_literal) @string.special
|
||||
(identifier) @constant
|
||||
(bind_parameter) @variable.parameter
|
||||
(comment) @comment
|
||||
|
||||
;;;
|
||||
|
||||
(ABORT) @keyword
|
||||
(ACTION) @keyword
|
||||
(ADD) @keyword
|
||||
(AFTER) @keyword
|
||||
(ALL) @keyword
|
||||
(ALTER) @keyword
|
||||
(ALWAYS) @keyword
|
||||
(ANALYZE) @keyword
|
||||
(AND) @keyword
|
||||
(AS) @keyword
|
||||
(ASC) @keyword
|
||||
(ATTACH) @keyword
|
||||
(AUTOINCREMENT) @keyword
|
||||
(BEFORE) @keyword
|
||||
(BEGIN) @keyword
|
||||
(BETWEEN) @keyword
|
||||
(BY) @keyword
|
||||
(CASCADE) @keyword
|
||||
(CASE) @keyword
|
||||
(CAST) @keyword
|
||||
(CHECK) @keyword
|
||||
(COLLATE) @keyword
|
||||
(COLUMN) @keyword
|
||||
(COMMIT) @keyword
|
||||
(CONFLICT) @keyword
|
||||
(CONSTRAINT) @keyword
|
||||
(CREATE) @keyword
|
||||
(CROSS) @keyword
|
||||
(CURRENT) @keyword
|
||||
(CURRENT_DATE) @keyword
|
||||
(CURRENT_TIME) @keyword
|
||||
(CURRENT_TIMESTAMP) @keyword
|
||||
(DATABASE) @keyword
|
||||
(DEFAULT) @keyword
|
||||
(DEFERRABLE) @keyword
|
||||
(DEFERRED) @keyword
|
||||
(DELETE) @keyword
|
||||
(DESC) @keyword
|
||||
(DETACH) @keyword
|
||||
(DISTINCT) @keyword
|
||||
(DO) @keyword
|
||||
(DROP) @keyword
|
||||
(EACH) @keyword
|
||||
(ELSE) @keyword
|
||||
(END) @keyword
|
||||
(ESCAPE) @keyword
|
||||
(EXCEPT) @keyword
|
||||
(EXCLUDE) @keyword
|
||||
(EXCLUSIVE) @keyword
|
||||
(EXISTS) @keyword
|
||||
(EXPLAIN) @keyword
|
||||
(FAIL) @keyword
|
||||
(FALSE) @keyword
|
||||
(FILTER) @keyword
|
||||
(FIRST) @keyword
|
||||
(FOLLOWING) @keyword
|
||||
(FOR) @keyword
|
||||
(FOREIGN) @keyword
|
||||
(FROM) @keyword
|
||||
(GENERATED) @keyword
|
||||
(GLOB) @keyword
|
||||
(GROUP) @keyword
|
||||
(GROUPS) @keyword
|
||||
(HAVING) @keyword
|
||||
(IF) @keyword
|
||||
(IGNORE) @keyword
|
||||
(IMMEDIATE) @keyword
|
||||
(IN) @keyword
|
||||
(INDEX) @keyword
|
||||
(INDEXED) @keyword
|
||||
(INITIALLY) @keyword
|
||||
(INNER) @keyword
|
||||
(INSERT) @keyword
|
||||
(INSTEAD) @keyword
|
||||
(INTERSECT) @keyword
|
||||
(INTO) @keyword
|
||||
(IS) @keyword
|
||||
(ISNULL) @keyword
|
||||
(JOIN) @keyword
|
||||
(KEY) @keyword
|
||||
(LAST) @keyword
|
||||
(LEFT) @keyword
|
||||
(LIKE) @keyword
|
||||
(LIMIT) @keyword
|
||||
(MATCH) @keyword
|
||||
(MATERIALIZED) @keyword
|
||||
(NATURAL) @keyword
|
||||
(NO) @keyword
|
||||
(NOT) @keyword
|
||||
(NOTHING) @keyword
|
||||
(NOTNULL) @keyword
|
||||
(NULL) @keyword
|
||||
(NULLS) @keyword
|
||||
(OF) @keyword
|
||||
(OFFSET) @keyword
|
||||
(ON) @keyword
|
||||
(OR) @keyword
|
||||
(ORDER) @keyword
|
||||
(OTHERS) @keyword
|
||||
(OUTER) @keyword
|
||||
(OVER) @keyword
|
||||
(PARTITION) @keyword
|
||||
(PLAN) @keyword
|
||||
(PRAGMA) @keyword
|
||||
(PRECEDING) @keyword
|
||||
(PRIMARY) @keyword
|
||||
(QUERY) @keyword
|
||||
(RAISE) @keyword
|
||||
(RANGE) @keyword
|
||||
(RECURSIVE) @keyword
|
||||
(REFERENCES) @keyword
|
||||
(REGEXP) @keyword
|
||||
(REINDEX) @keyword
|
||||
(RELEASE) @keyword
|
||||
(RENAME) @keyword
|
||||
(REPLACE) @keyword
|
||||
(RESTRICT) @keyword
|
||||
(RETURNING) @keyword
|
||||
(ROLLBACK) @keyword
|
||||
(ROW) @keyword
|
||||
(ROWID) @keyword
|
||||
(ROWS) @keyword
|
||||
(SAVEPOINT) @keyword
|
||||
(SELECT) @keyword
|
||||
(SET) @keyword
|
||||
(STORED) @keyword
|
||||
(TABLE) @keyword
|
||||
(TEMP) @keyword
|
||||
(TEMPORARY) @keyword
|
||||
(THEN) @keyword
|
||||
(TIES) @keyword
|
||||
(TO) @keyword
|
||||
(TRANSACTION) @keyword
|
||||
(TRIGGER) @keyword
|
||||
(TRUE) @keyword
|
||||
(UNBOUNDED) @keyword
|
||||
(UNION) @keyword
|
||||
(UNIQUE) @keyword
|
||||
(UPDATE) @keyword
|
||||
(USING) @keyword
|
||||
(VACUUM) @keyword
|
||||
(VALUES) @keyword
|
||||
(VIEW) @keyword
|
||||
(VIRTUAL) @keyword
|
||||
(WHEN) @keyword
|
||||
(WHERE) @keyword
|
||||
(WINDOW) @keyword
|
||||
(WITH) @keyword
|
||||
(WITHOUT) @keyword
|
||||
@@ -0,0 +1,42 @@
|
||||
; inherits: html
|
||||
|
||||
(raw_text) @none
|
||||
|
||||
[
|
||||
"as"
|
||||
"key"
|
||||
"html"
|
||||
"snippet"
|
||||
"render"
|
||||
] @keyword
|
||||
|
||||
"const" @type.qualifier
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"then"
|
||||
] @keyword.conditional
|
||||
|
||||
"each" @keyword.repeat
|
||||
|
||||
[
|
||||
"await"
|
||||
"then"
|
||||
] @keyword.coroutine
|
||||
|
||||
"catch" @keyword.exception
|
||||
|
||||
"debug" @keyword.debug
|
||||
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"#"
|
||||
":"
|
||||
"/"
|
||||
"@"
|
||||
] @tag.delimiter
|
||||
@@ -0,0 +1,62 @@
|
||||
[
|
||||
"if" "else" "guard"
|
||||
"for" "while" "repeat"
|
||||
"switch" "case" "default" "fallthrough"
|
||||
"break" "continue" "return" "throw"
|
||||
"do" "catch" "try" "defer"
|
||||
"import"
|
||||
"class" "struct" "enum" "protocol" "extension" "typealias" "associatedtype"
|
||||
"func" "init" "deinit" "subscript" "operator"
|
||||
"var" "let"
|
||||
"static" "override" "mutating" "nonmutating"
|
||||
"public" "private" "fileprivate" "internal" "open"
|
||||
"final" "required" "convenience" "lazy" "weak" "unowned"
|
||||
"async" "await"
|
||||
"where" "in" "is" "as"
|
||||
"self" "super" "Self"
|
||||
"nil"
|
||||
"true" "false"
|
||||
"inout" "some" "any"
|
||||
"get" "set" "willSet" "didSet"
|
||||
"throws" "rethrows"
|
||||
"indirect"
|
||||
"precedencegroup" "infix" "prefix" "postfix"
|
||||
] @keyword
|
||||
|
||||
(function_declaration (identifier) @function)
|
||||
(initializer_declaration "init" @function)
|
||||
|
||||
(class_declaration (identifier) @type)
|
||||
(struct_declaration (identifier) @type)
|
||||
(enum_declaration (identifier) @type)
|
||||
(protocol_declaration (identifier) @type)
|
||||
(typealias_declaration (identifier) @type)
|
||||
(type_identifier) @type
|
||||
(standard_type) @type.builtin
|
||||
|
||||
(string) @string
|
||||
(static_string_literal) @string
|
||||
|
||||
(number) @number
|
||||
(boolean_literal) @boolean
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
(modifier) @keyword
|
||||
|
||||
[
|
||||
"(" ")" "[" "]" "{" "}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"," "." ":" ";" "->" "=>"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"=" "+" "-" "*" "/" "%"
|
||||
"==" "!=" "<" ">" "<=" ">="
|
||||
"&&" "||" "!"
|
||||
"&" "|" "^" "~"
|
||||
"?" "??"
|
||||
"..<" "..."
|
||||
] @operator
|
||||
@@ -0,0 +1,53 @@
|
||||
; Properties
|
||||
;-----------
|
||||
|
||||
(bare_key) @type
|
||||
|
||||
(quoted_key) @string
|
||||
|
||||
(pair
|
||||
(bare_key)) @property
|
||||
|
||||
(pair
|
||||
(dotted_key
|
||||
(bare_key) @property))
|
||||
|
||||
; Literals
|
||||
;---------
|
||||
|
||||
(boolean) @boolean
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(string) @string
|
||||
|
||||
[
|
||||
(integer)
|
||||
(float)
|
||||
] @number
|
||||
|
||||
[
|
||||
(offset_date_time)
|
||||
(local_date_time)
|
||||
(local_date)
|
||||
(local_time)
|
||||
] @string.special
|
||||
|
||||
; Punctuation
|
||||
;------------
|
||||
|
||||
[
|
||||
"."
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
"=" @operator
|
||||
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"[["
|
||||
"]]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
@@ -0,0 +1,35 @@
|
||||
; Types
|
||||
|
||||
(type_identifier) @type
|
||||
(predefined_type) @type.builtin
|
||||
|
||||
((identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
(type_arguments
|
||||
"<" @punctuation.bracket
|
||||
">" @punctuation.bracket)
|
||||
|
||||
; Variables
|
||||
|
||||
(required_parameter (identifier) @variable.parameter)
|
||||
(optional_parameter (identifier) @variable.parameter)
|
||||
|
||||
; Keywords
|
||||
|
||||
[ "abstract"
|
||||
"declare"
|
||||
"enum"
|
||||
"export"
|
||||
"implements"
|
||||
"interface"
|
||||
"keyof"
|
||||
"namespace"
|
||||
"private"
|
||||
"protected"
|
||||
"public"
|
||||
"type"
|
||||
"readonly"
|
||||
"override"
|
||||
"satisfies"
|
||||
] @keyword
|
||||
@@ -0,0 +1,54 @@
|
||||
; inherits: html_tags
|
||||
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
":"
|
||||
"."
|
||||
] @character.special
|
||||
|
||||
[
|
||||
(interpolation)
|
||||
"@"
|
||||
] @punctuation.special
|
||||
|
||||
(interpolation
|
||||
(raw_text) @none)
|
||||
|
||||
(dynamic_directive_inner_value) @variable
|
||||
|
||||
(directive_name) @tag.attribute
|
||||
|
||||
; Accessing a component object's field
|
||||
(":"
|
||||
.
|
||||
(directive_value) @variable.member)
|
||||
|
||||
("."
|
||||
.
|
||||
(directive_value) @property)
|
||||
|
||||
; @click is like onclick for HTML
|
||||
("@"
|
||||
.
|
||||
(directive_value) @function.method)
|
||||
|
||||
; Used in v-slot, declaring position the element should be put in
|
||||
("#"
|
||||
.
|
||||
(directive_value) @variable)
|
||||
|
||||
(directive_attribute
|
||||
(quoted_attribute_value) @punctuation.special)
|
||||
|
||||
(directive_attribute
|
||||
(quoted_attribute_value
|
||||
(attribute_value) @none))
|
||||
|
||||
(directive_modifier) @function.method
|
||||
|
||||
((template_element) @_template
|
||||
(#set! @_template bo.commentstring "<!-- %s -->"))
|
||||
@@ -0,0 +1,111 @@
|
||||
(int_literal) @number
|
||||
(float_literal) @float
|
||||
(bool_literal) @boolean
|
||||
|
||||
(type_declaration [ "bool" "u32" "i32" "f16" "f32" ] @type.builtin)
|
||||
(type_declaration) @type
|
||||
|
||||
(function_declaration
|
||||
(identifier) @function)
|
||||
|
||||
(parameter
|
||||
(variable_identifier_declaration (identifier) @parameter))
|
||||
|
||||
(struct_declaration
|
||||
(identifier) @structure)
|
||||
|
||||
(struct_declaration
|
||||
(struct_member (variable_identifier_declaration (identifier) @field)))
|
||||
|
||||
(attribute
|
||||
(identifier) @attribute)
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
(type_constructor_or_function_call_expression
|
||||
(type_declaration) @function.call)
|
||||
|
||||
[
|
||||
"struct"
|
||||
"bitcast"
|
||||
"discard"
|
||||
"enable"
|
||||
"fallthrough"
|
||||
"let"
|
||||
"type"
|
||||
"var"
|
||||
"override"
|
||||
(texel_format)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"private"
|
||||
"storage"
|
||||
"uniform"
|
||||
"workgroup"
|
||||
] @storageclass
|
||||
|
||||
[
|
||||
"read"
|
||||
"read_write"
|
||||
"write"
|
||||
] @type.qualifier
|
||||
|
||||
"fn" @keyword.function
|
||||
|
||||
"return" @keyword.return
|
||||
|
||||
[ "," "." ":" ";" "->" ] @punctuation.delimiter
|
||||
|
||||
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
|
||||
|
||||
[
|
||||
"loop"
|
||||
"for"
|
||||
"while"
|
||||
"break"
|
||||
"continue"
|
||||
"continuing"
|
||||
] @repeat
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
"case"
|
||||
"default"
|
||||
] @conditional
|
||||
|
||||
[
|
||||
"&"
|
||||
"&&"
|
||||
"/"
|
||||
"!"
|
||||
"="
|
||||
"=="
|
||||
"!="
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
"<"
|
||||
"<="
|
||||
"<<"
|
||||
"%"
|
||||
"-"
|
||||
"+"
|
||||
"|"
|
||||
"||"
|
||||
"*"
|
||||
"~"
|
||||
"^"
|
||||
"@"
|
||||
"++"
|
||||
"--"
|
||||
] @operator
|
||||
|
||||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment
|
||||
|
||||
(ERROR) @error
|
||||
@@ -0,0 +1,168 @@
|
||||
;; XML declaration
|
||||
|
||||
"xml" @keyword
|
||||
|
||||
[ "version" "encoding" "standalone" ] @property
|
||||
|
||||
(EncName) @string.special
|
||||
|
||||
(VersionNum) @number
|
||||
|
||||
[ "yes" "no" ] @boolean
|
||||
|
||||
;; Processing instructions
|
||||
|
||||
(PI) @embedded
|
||||
|
||||
(PI (PITarget) @keyword)
|
||||
|
||||
;; Element declaration
|
||||
|
||||
(elementdecl
|
||||
"ELEMENT" @keyword
|
||||
(Name) @tag)
|
||||
|
||||
(contentspec
|
||||
(_ (Name) @property))
|
||||
|
||||
"#PCDATA" @type.builtin
|
||||
|
||||
[ "EMPTY" "ANY" ] @string.special.symbol
|
||||
|
||||
[ "*" "?" "+" ] @operator
|
||||
|
||||
;; Entity declaration
|
||||
|
||||
(GEDecl
|
||||
"ENTITY" @keyword
|
||||
(Name) @constant)
|
||||
|
||||
(GEDecl (EntityValue) @string)
|
||||
|
||||
(NDataDecl
|
||||
"NDATA" @keyword
|
||||
(Name) @label)
|
||||
|
||||
;; Parsed entity declaration
|
||||
|
||||
(PEDecl
|
||||
"ENTITY" @keyword
|
||||
"%" @operator
|
||||
(Name) @constant)
|
||||
|
||||
(PEDecl (EntityValue) @string)
|
||||
|
||||
;; Notation declaration
|
||||
|
||||
(NotationDecl
|
||||
"NOTATION" @keyword
|
||||
(Name) @constant)
|
||||
|
||||
(NotationDecl
|
||||
(ExternalID
|
||||
(SystemLiteral (URI) @string.special)))
|
||||
|
||||
;; Attlist declaration
|
||||
|
||||
(AttlistDecl
|
||||
"ATTLIST" @keyword
|
||||
(Name) @tag)
|
||||
|
||||
(AttDef (Name) @property)
|
||||
|
||||
(AttDef (Enumeration (Nmtoken) @string))
|
||||
|
||||
(DefaultDecl (AttValue) @string)
|
||||
|
||||
[
|
||||
(StringType)
|
||||
(TokenizedType)
|
||||
] @type.builtin
|
||||
|
||||
(NotationType "NOTATION" @type.builtin)
|
||||
|
||||
[
|
||||
"#REQUIRED"
|
||||
"#IMPLIED"
|
||||
"#FIXED"
|
||||
] @attribute
|
||||
|
||||
;; Entities
|
||||
|
||||
(EntityRef) @constant
|
||||
|
||||
((EntityRef) @constant.builtin
|
||||
(#any-of? @constant.builtin
|
||||
"&" "<" ">" """ "'"))
|
||||
|
||||
(CharRef) @constant
|
||||
|
||||
(PEReference) @constant
|
||||
|
||||
;; External references
|
||||
|
||||
[ "PUBLIC" "SYSTEM" ] @keyword
|
||||
|
||||
(PubidLiteral) @string.special
|
||||
|
||||
(SystemLiteral (URI) @markup.link)
|
||||
|
||||
;; Processing instructions
|
||||
|
||||
(XmlModelPI "xml-model" @keyword)
|
||||
|
||||
(StyleSheetPI "xml-stylesheet" @keyword)
|
||||
|
||||
(PseudoAtt (Name) @property)
|
||||
|
||||
(PseudoAtt (PseudoAttValue) @string)
|
||||
|
||||
;; Doctype declaration
|
||||
|
||||
(doctypedecl "DOCTYPE" @keyword)
|
||||
|
||||
(doctypedecl (Name) @type)
|
||||
|
||||
;; Tags
|
||||
|
||||
(STag (Name) @tag)
|
||||
|
||||
(ETag (Name) @tag)
|
||||
|
||||
(EmptyElemTag (Name) @tag)
|
||||
|
||||
;; Attributes
|
||||
|
||||
(Attribute (Name) @property)
|
||||
|
||||
(Attribute (AttValue) @string)
|
||||
|
||||
;; Delimiters & punctuation
|
||||
|
||||
[
|
||||
"<?" "?>"
|
||||
"<!" "]]>"
|
||||
"<" ">"
|
||||
"</" "/>"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[ "(" ")" "[" "]" ] @punctuation.bracket
|
||||
|
||||
[ "\"" "'" ] @punctuation.delimiter
|
||||
|
||||
[ "," "|" "=" ] @operator
|
||||
|
||||
;; Text
|
||||
|
||||
(CharData) @markup
|
||||
|
||||
(CDSect
|
||||
(CDStart) @markup.heading
|
||||
(CData) @markup.raw
|
||||
"]]>" @markup.heading)
|
||||
|
||||
;; Misc
|
||||
|
||||
(Comment) @comment
|
||||
|
||||
(ERROR) @error
|
||||
@@ -0,0 +1,79 @@
|
||||
(boolean_scalar) @boolean
|
||||
|
||||
(null_scalar) @constant.builtin
|
||||
|
||||
[
|
||||
(double_quote_scalar)
|
||||
(single_quote_scalar)
|
||||
(block_scalar)
|
||||
(string_scalar)
|
||||
] @string
|
||||
|
||||
[
|
||||
(integer_scalar)
|
||||
(float_scalar)
|
||||
] @number
|
||||
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
(anchor_name)
|
||||
(alias_name)
|
||||
] @label
|
||||
|
||||
(tag) @type
|
||||
|
||||
[
|
||||
(yaml_directive)
|
||||
(tag_directive)
|
||||
(reserved_directive)
|
||||
] @attribute
|
||||
|
||||
(block_mapping_pair
|
||||
key: (flow_node
|
||||
[
|
||||
(double_quote_scalar)
|
||||
(single_quote_scalar)
|
||||
] @property))
|
||||
|
||||
(block_mapping_pair
|
||||
key: (flow_node
|
||||
(plain_scalar
|
||||
(string_scalar) @property)))
|
||||
|
||||
(flow_mapping
|
||||
(_
|
||||
key: (flow_node
|
||||
[
|
||||
(double_quote_scalar)
|
||||
(single_quote_scalar)
|
||||
] @property)))
|
||||
|
||||
(flow_mapping
|
||||
(_
|
||||
key: (flow_node
|
||||
(plain_scalar
|
||||
(string_scalar) @property))))
|
||||
|
||||
[
|
||||
","
|
||||
"-"
|
||||
":"
|
||||
">"
|
||||
"?"
|
||||
"|"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"*"
|
||||
"&"
|
||||
"---"
|
||||
"..."
|
||||
] @punctuation.special
|
||||
@@ -0,0 +1,283 @@
|
||||
; Variables
|
||||
(identifier) @variable
|
||||
|
||||
; Parameters
|
||||
(parameter
|
||||
name: (identifier) @variable.parameter)
|
||||
|
||||
(payload
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
; Types
|
||||
(parameter
|
||||
type: (identifier) @type)
|
||||
|
||||
((identifier) @type
|
||||
(#lua-match? @type "^[A-Z_][a-zA-Z0-9_]*"))
|
||||
|
||||
(variable_declaration
|
||||
(identifier) @type
|
||||
"="
|
||||
[
|
||||
(struct_declaration)
|
||||
(enum_declaration)
|
||||
(union_declaration)
|
||||
(opaque_declaration)
|
||||
])
|
||||
|
||||
[
|
||||
(builtin_type)
|
||||
"anyframe"
|
||||
] @type.builtin
|
||||
|
||||
; Constants
|
||||
((identifier) @constant
|
||||
(#lua-match? @constant "^[A-Z][A-Z_0-9]+$"))
|
||||
|
||||
[
|
||||
"null"
|
||||
"unreachable"
|
||||
"undefined"
|
||||
] @constant.builtin
|
||||
|
||||
(field_expression
|
||||
.
|
||||
member: (identifier) @constant)
|
||||
|
||||
(enum_declaration
|
||||
(container_field
|
||||
type: (identifier) @constant))
|
||||
|
||||
; Labels
|
||||
(block_label
|
||||
(identifier) @label)
|
||||
|
||||
(break_label
|
||||
(identifier) @label)
|
||||
|
||||
; Fields
|
||||
(field_initializer
|
||||
.
|
||||
(identifier) @variable.member)
|
||||
|
||||
(field_expression
|
||||
(_)
|
||||
member: (identifier) @variable.member)
|
||||
|
||||
(container_field
|
||||
name: (identifier) @variable.member)
|
||||
|
||||
(initializer_list
|
||||
(assignment_expression
|
||||
left: (field_expression
|
||||
.
|
||||
member: (identifier) @variable.member)))
|
||||
|
||||
; Functions
|
||||
(builtin_identifier) @function.builtin
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
function: (field_expression
|
||||
member: (identifier) @function.call))
|
||||
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
; Modules
|
||||
(variable_declaration
|
||||
(identifier) @module
|
||||
(builtin_function
|
||||
(builtin_identifier) @keyword.import
|
||||
(#any-of? @keyword.import "@import" "@cImport")))
|
||||
|
||||
; Builtins
|
||||
[
|
||||
"c"
|
||||
"..."
|
||||
] @variable.builtin
|
||||
|
||||
((identifier) @variable.builtin
|
||||
(#eq? @variable.builtin "_"))
|
||||
|
||||
(calling_convention
|
||||
(identifier) @variable.builtin)
|
||||
|
||||
; Keywords
|
||||
[
|
||||
"asm"
|
||||
"defer"
|
||||
"errdefer"
|
||||
"test"
|
||||
"error"
|
||||
"const"
|
||||
"var"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"struct"
|
||||
"union"
|
||||
"enum"
|
||||
"opaque"
|
||||
] @keyword.type
|
||||
|
||||
[
|
||||
"async"
|
||||
"await"
|
||||
"suspend"
|
||||
"nosuspend"
|
||||
"resume"
|
||||
] @keyword.coroutine
|
||||
|
||||
"fn" @keyword.function
|
||||
|
||||
[
|
||||
"and"
|
||||
"or"
|
||||
"orelse"
|
||||
] @keyword.operator
|
||||
|
||||
"return" @keyword.return
|
||||
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
] @keyword.conditional
|
||||
|
||||
[
|
||||
"for"
|
||||
"while"
|
||||
"break"
|
||||
"continue"
|
||||
] @keyword.repeat
|
||||
|
||||
[
|
||||
"usingnamespace"
|
||||
"export"
|
||||
] @keyword.import
|
||||
|
||||
[
|
||||
"try"
|
||||
"catch"
|
||||
] @keyword.exception
|
||||
|
||||
[
|
||||
"volatile"
|
||||
"allowzero"
|
||||
"noalias"
|
||||
"addrspace"
|
||||
"align"
|
||||
"callconv"
|
||||
"linksection"
|
||||
"pub"
|
||||
"inline"
|
||||
"noinline"
|
||||
"extern"
|
||||
"comptime"
|
||||
"packed"
|
||||
"threadlocal"
|
||||
] @keyword.modifier
|
||||
|
||||
; Operator
|
||||
[
|
||||
"="
|
||||
"*="
|
||||
"*%="
|
||||
"*|="
|
||||
"/="
|
||||
"%="
|
||||
"+="
|
||||
"+%="
|
||||
"+|="
|
||||
"-="
|
||||
"-%="
|
||||
"-|="
|
||||
"<<="
|
||||
"<<|="
|
||||
">>="
|
||||
"&="
|
||||
"^="
|
||||
"|="
|
||||
"!"
|
||||
"~"
|
||||
"-"
|
||||
"-%"
|
||||
"&"
|
||||
"=="
|
||||
"!="
|
||||
">"
|
||||
">="
|
||||
"<="
|
||||
"<"
|
||||
"&"
|
||||
"^"
|
||||
"|"
|
||||
"<<"
|
||||
">>"
|
||||
"<<|"
|
||||
"+"
|
||||
"++"
|
||||
"+%"
|
||||
"-%"
|
||||
"+|"
|
||||
"-|"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"**"
|
||||
"*%"
|
||||
"*|"
|
||||
"||"
|
||||
".*"
|
||||
".?"
|
||||
"?"
|
||||
".."
|
||||
] @operator
|
||||
|
||||
; Literals
|
||||
(character) @character
|
||||
|
||||
([
|
||||
(string)
|
||||
(multiline_string)
|
||||
] @string
|
||||
(#set! "priority" 95))
|
||||
|
||||
(integer) @number
|
||||
|
||||
(float) @number.float
|
||||
|
||||
(boolean) @boolean
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
; Punctuation
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
";"
|
||||
"."
|
||||
","
|
||||
":"
|
||||
"=>"
|
||||
"->"
|
||||
] @punctuation.delimiter
|
||||
|
||||
(payload
|
||||
"|" @punctuation.bracket)
|
||||
|
||||
; Comments
|
||||
(comment) @comment @spell
|
||||
|
||||
((comment) @comment.documentation
|
||||
(#lua-match? @comment.documentation "^//!"))
|
||||
@@ -2,11 +2,13 @@ import 'dart:async';
|
||||
|
||||
import 'package:clide/clide.dart';
|
||||
import 'package:clide_app/kernel/kernel.dart';
|
||||
import 'package:clide_app/kernel/src/syntax/tree_sitter_service.dart';
|
||||
import 'package:clide_app/widgets/widgets.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'editor_controller.dart';
|
||||
import 'syntax_text_controller.dart';
|
||||
|
||||
/// Tier-2 editor tab. One tab — the content reflects the daemon's
|
||||
/// active buffer. Multi-file tabs live in the workspace-slot plan but
|
||||
@@ -25,14 +27,15 @@ class EditorView extends StatefulWidget {
|
||||
|
||||
class _EditorViewState extends State<EditorView> {
|
||||
EditorController? _controller;
|
||||
late final TextEditingController _text;
|
||||
final TreeSitterService _syntax = TreeSitterService();
|
||||
late final SyntaxTextController _text;
|
||||
late final FocusNode _focus;
|
||||
String? _lastRemoteContent;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_text = TextEditingController();
|
||||
_text = SyntaxTextController(syntax: _syntax);
|
||||
_focus = FocusNode();
|
||||
_text.addListener(_onTextChanged);
|
||||
}
|
||||
@@ -54,11 +57,13 @@ class _EditorViewState extends State<EditorView> {
|
||||
_focus.dispose();
|
||||
_controller?.removeListener(_onControllerChanged);
|
||||
_controller?.dispose();
|
||||
_syntax.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onControllerChanged() {
|
||||
final c = _controller!;
|
||||
_text.updatePath(c.activePath);
|
||||
if (c.content != _lastRemoteContent) {
|
||||
_lastRemoteContent = c.content;
|
||||
final sel = TextSelection(
|
||||
@@ -110,6 +115,7 @@ class _EditorViewState extends State<EditorView> {
|
||||
Widget build(BuildContext context) {
|
||||
final c = _controller;
|
||||
final tokens = ClideTheme.of(context).surface;
|
||||
_text.tokens = tokens;
|
||||
if (c == null) return const SizedBox.shrink();
|
||||
|
||||
return ListenableBuilder(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user