logiguard fork v3: full patch set on verified 8c74db0 tree
Includes prior-session patches (carry forward so the app compiles): - crates/gpui/build.rs: cross-compile manifest fix - crates/gpui/src/platform.rs: PlatformWindow::activate_with_token trait method - crates/gpui/src/window.rs: Window::activate_with_token public API - crates/gpui_linux/src/linux/wayland/window.rs: WaylandWindow::activate_with_token + activate() keyboard-serial fix Plus the focus-serial fix: - serial.rs: SerialKind::KeyboardEnter - client.rs: store wl_keyboard.enter serial; latest_serial_of() Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
60
crates/grammars/Cargo.toml
Normal file
60
crates/grammars/Cargo.toml
Normal file
@@ -0,0 +1,60 @@
|
||||
[package]
|
||||
name = "grammars"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
path = "src/grammars.rs"
|
||||
|
||||
[dependencies]
|
||||
language_core.workspace = true
|
||||
rust-embed.workspace = true
|
||||
anyhow.workspace = true
|
||||
toml.workspace = true
|
||||
util.workspace = true
|
||||
|
||||
tree-sitter = { workspace = true, optional = true }
|
||||
tree-sitter-bash = { workspace = true, optional = true }
|
||||
tree-sitter-c = { workspace = true, optional = true }
|
||||
tree-sitter-cpp = { workspace = true, optional = true }
|
||||
tree-sitter-css = { workspace = true, optional = true }
|
||||
tree-sitter-diff = { workspace = true, optional = true }
|
||||
tree-sitter-gitcommit = { workspace = true, optional = true }
|
||||
tree-sitter-go = { workspace = true, optional = true }
|
||||
tree-sitter-go-mod = { workspace = true, optional = true }
|
||||
tree-sitter-gowork = { workspace = true, optional = true }
|
||||
tree-sitter-jsdoc = { workspace = true, optional = true }
|
||||
tree-sitter-json = { workspace = true, optional = true }
|
||||
tree-sitter-md = { workspace = true, optional = true }
|
||||
tree-sitter-python = { workspace = true, optional = true }
|
||||
tree-sitter-regex = { workspace = true, optional = true }
|
||||
tree-sitter-rust = { workspace = true, optional = true }
|
||||
tree-sitter-typescript = { workspace = true, optional = true }
|
||||
tree-sitter-yaml = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
load-grammars = [
|
||||
"tree-sitter",
|
||||
"tree-sitter-bash",
|
||||
"tree-sitter-c",
|
||||
"tree-sitter-cpp",
|
||||
"tree-sitter-css",
|
||||
"tree-sitter-diff",
|
||||
"tree-sitter-gitcommit",
|
||||
"tree-sitter-go",
|
||||
"tree-sitter-go-mod",
|
||||
"tree-sitter-gowork",
|
||||
"tree-sitter-jsdoc",
|
||||
"tree-sitter-json",
|
||||
"tree-sitter-md",
|
||||
"tree-sitter-python",
|
||||
"tree-sitter-regex",
|
||||
"tree-sitter-rust",
|
||||
"tree-sitter-typescript",
|
||||
"tree-sitter-yaml",
|
||||
]
|
||||
test-support = ["load-grammars"]
|
||||
1
crates/grammars/LICENSE-GPL
Symbolic link
1
crates/grammars/LICENSE-GPL
Symbolic link
@@ -0,0 +1 @@
|
||||
../../LICENSE-GPL
|
||||
62
crates/grammars/src/bash/brackets.scm
Normal file
62
crates/grammars/src/bash/brackets.scm
Normal file
@@ -0,0 +1,62 @@
|
||||
("(" @open
|
||||
")" @close)
|
||||
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
|
||||
(("\"" @open
|
||||
"\"" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("`" @open
|
||||
"`" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("do" @open
|
||||
"done" @close)
|
||||
(#set! newline.only)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
((case_statement
|
||||
("in" @open
|
||||
"esac" @close))
|
||||
(#set! newline.only)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
((if_statement
|
||||
(elif_clause
|
||||
"then" @open)
|
||||
(else_clause
|
||||
"else" @close))
|
||||
(#set! newline.only)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
((if_statement
|
||||
(else_clause
|
||||
"else" @open)
|
||||
"fi" @close)
|
||||
(#set! newline.only)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
((if_statement
|
||||
"then" @open
|
||||
(elif_clause
|
||||
"elif" @close))
|
||||
(#set! newline.only)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
((if_statement
|
||||
"then" @open
|
||||
(else_clause
|
||||
"else" @close))
|
||||
(#set! newline.only)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
((if_statement
|
||||
("then" @open
|
||||
"fi" @close))
|
||||
(#set! newline.only)
|
||||
(#set! rainbow.exclude))
|
||||
38
crates/grammars/src/bash/config.toml
Normal file
38
crates/grammars/src/bash/config.toml
Normal file
@@ -0,0 +1,38 @@
|
||||
name = "Shell Script"
|
||||
code_fence_block_name = "bash"
|
||||
grammar = "bash"
|
||||
path_suffixes = ["sh", "bash", "bashrc", "bash_profile", "bash_aliases", "bash_logout", "bats", "profile", "zsh", "zshrc", "zshenv", "zsh_profile", "zsh_aliases", "zsh_histfile", "zlogin", "zprofile", ".env", "PKGBUILD", "APKBUILD"]
|
||||
modeline_aliases = ["sh", "shell", "zsh", "fish"]
|
||||
line_comments = ["# "]
|
||||
first_line_pattern = '^#!.*\b(?:ash|bash|bats|dash|sh|zsh)\b'
|
||||
autoclose_before = "}])"
|
||||
brackets = [
|
||||
{ start = "[", end = "]", close = true, newline = false },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] },
|
||||
{ start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
||||
{ start = "do", end = "done", close = false, newline = true, not_in = ["comment", "string"] },
|
||||
{ start = "then", end = "fi", close = false, newline = true, not_in = ["comment", "string"] },
|
||||
{ start = "then", end = "else", close = false, newline = true, not_in = ["comment", "string"] },
|
||||
{ start = "then", end = "elif", close = false, newline = true, not_in = ["comment", "string"] },
|
||||
{ start = "in", end = "esac", close = false, newline = true, not_in = ["comment", "string"] },
|
||||
]
|
||||
|
||||
auto_indent_using_last_non_empty_line = false
|
||||
increase_indent_pattern = "^\\s*(\\b(else|elif)\\b|([^#]+\\b(do|then|in)\\b)|([\\w\\*]+\\)))\\s*$"
|
||||
decrease_indent_patterns = [
|
||||
{ pattern = "^\\s*elif\\b.*", valid_after = ["if", "elif"] },
|
||||
{ pattern = "^\\s*else\\b.*", valid_after = ["if", "elif", "for", "while"] },
|
||||
{ pattern = "^\\s*fi\\b.*", valid_after = ["if", "elif", "else"] },
|
||||
{ pattern = "^\\s*done\\b.*", valid_after = ["for", "while"] },
|
||||
{ pattern = "^\\s*esac\\b.*", valid_after = ["case"] },
|
||||
{ pattern = "^\\s*[\\w\\*]+\\)\\s*$", valid_after = ["case_item"] },
|
||||
]
|
||||
|
||||
# We can't use decrease_indent_patterns simply for elif, because
|
||||
# there is bug in tree sitter which throws ERROR on if match.
|
||||
#
|
||||
# This is workaround. That means, elif will outdents with despite
|
||||
# of wrong context. Like using elif after else.
|
||||
decrease_indent_pattern = "(^|\\s+|;)(elif)\\b.*$"
|
||||
124
crates/grammars/src/bash/highlights.scm
Normal file
124
crates/grammars/src/bash/highlights.scm
Normal file
@@ -0,0 +1,124 @@
|
||||
[
|
||||
(string)
|
||||
(raw_string)
|
||||
(heredoc_body)
|
||||
(heredoc_start)
|
||||
(heredoc_end)
|
||||
(ansi_c_string)
|
||||
(word)
|
||||
] @string
|
||||
|
||||
(variable_name) @variable
|
||||
|
||||
[
|
||||
"export"
|
||||
"function"
|
||||
"unset"
|
||||
"local"
|
||||
"declare"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"case"
|
||||
"do"
|
||||
"done"
|
||||
"elif"
|
||||
"else"
|
||||
"esac"
|
||||
"fi"
|
||||
"for"
|
||||
"if"
|
||||
"in"
|
||||
"select"
|
||||
"then"
|
||||
"until"
|
||||
"while"
|
||||
] @keyword.control
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; Shebang
|
||||
((program
|
||||
.
|
||||
(comment) @keyword.directive)
|
||||
(#match? @keyword.directive "^#![ \t]*/"))
|
||||
|
||||
(function_definition
|
||||
name: (word) @function)
|
||||
|
||||
(command_name
|
||||
(word) @function)
|
||||
|
||||
(command
|
||||
argument: [
|
||||
(word) @variable.parameter
|
||||
(_
|
||||
(word) @variable.parameter)
|
||||
])
|
||||
|
||||
[
|
||||
(file_descriptor)
|
||||
(number)
|
||||
] @number
|
||||
|
||||
(regex) @string.regex
|
||||
|
||||
[
|
||||
(command_substitution)
|
||||
(process_substitution)
|
||||
(expansion)
|
||||
] @embedded
|
||||
|
||||
[
|
||||
"$"
|
||||
"&&"
|
||||
">"
|
||||
"<<"
|
||||
">>"
|
||||
">&"
|
||||
">&-"
|
||||
"<"
|
||||
"|"
|
||||
":"
|
||||
"//"
|
||||
"/"
|
||||
"%"
|
||||
"%%"
|
||||
"#"
|
||||
"##"
|
||||
"="
|
||||
"=="
|
||||
] @operator
|
||||
|
||||
(test_operator) @keyword.operator
|
||||
|
||||
";" @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
(simple_expansion
|
||||
"$" @punctuation.special)
|
||||
|
||||
(expansion
|
||||
"${" @punctuation.special
|
||||
"}" @punctuation.special) @embedded
|
||||
|
||||
(command_substitution
|
||||
"$(" @punctuation.special
|
||||
")" @punctuation.special)
|
||||
|
||||
((command
|
||||
(_) @constant)
|
||||
(#match? @constant "^-"))
|
||||
|
||||
(case_item
|
||||
value: (_) @string.regex)
|
||||
|
||||
(special_variable_name) @variable.special
|
||||
27
crates/grammars/src/bash/indents.scm
Normal file
27
crates/grammars/src/bash/indents.scm
Normal file
@@ -0,0 +1,27 @@
|
||||
(_
|
||||
"["
|
||||
"]" @end) @indent
|
||||
|
||||
(_
|
||||
"{"
|
||||
"}" @end) @indent
|
||||
|
||||
(_
|
||||
"("
|
||||
")" @end) @indent
|
||||
|
||||
(function_definition) @start.function
|
||||
|
||||
(if_statement) @start.if
|
||||
|
||||
(elif_clause) @start.elif
|
||||
|
||||
(else_clause) @start.else
|
||||
|
||||
(for_statement) @start.for
|
||||
|
||||
(while_statement) @start.while
|
||||
|
||||
(case_statement) @start.case
|
||||
|
||||
(case_item) @start.case_item
|
||||
2
crates/grammars/src/bash/injections.scm
Normal file
2
crates/grammars/src/bash/injections.scm
Normal file
@@ -0,0 +1,2 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
3
crates/grammars/src/bash/overrides.scm
Normal file
3
crates/grammars/src/bash/overrides.scm
Normal file
@@ -0,0 +1,3 @@
|
||||
(comment) @comment.inclusive
|
||||
|
||||
(string) @string
|
||||
2
crates/grammars/src/bash/redactions.scm
Normal file
2
crates/grammars/src/bash/redactions.scm
Normal file
@@ -0,0 +1,2 @@
|
||||
(variable_assignment
|
||||
value: (_) @redact)
|
||||
5
crates/grammars/src/bash/runnables.scm
Normal file
5
crates/grammars/src/bash/runnables.scm
Normal file
@@ -0,0 +1,5 @@
|
||||
; Run bash scripts
|
||||
((program
|
||||
.
|
||||
(_) @run) @_bash-script
|
||||
(#set! tag bash-script))
|
||||
7
crates/grammars/src/bash/textobjects.scm
Normal file
7
crates/grammars/src/bash/textobjects.scm
Normal file
@@ -0,0 +1,7 @@
|
||||
(function_definition
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
(comment) @comment.around
|
||||
16
crates/grammars/src/c/brackets.scm
Normal file
16
crates/grammars/src/c/brackets.scm
Normal file
@@ -0,0 +1,16 @@
|
||||
("(" @open
|
||||
")" @close)
|
||||
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
|
||||
(("\"" @open
|
||||
"\"" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("'" @open
|
||||
"'" @close)
|
||||
(#set! rainbow.exclude))
|
||||
20
crates/grammars/src/c/config.toml
Normal file
20
crates/grammars/src/c/config.toml
Normal file
@@ -0,0 +1,20 @@
|
||||
name = "C"
|
||||
grammar = "c"
|
||||
path_suffixes = ["c"]
|
||||
line_comments = ["// "]
|
||||
decrease_indent_patterns = [
|
||||
{ pattern = "^\\s*\\{.*\\}?\\s*$", valid_after = ["if", "for", "while", "do", "switch", "else"] },
|
||||
{ pattern = "^\\s*else\\b", valid_after = ["if"] }
|
||||
]
|
||||
autoclose_before = ";:.,=}])>"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
|
||||
{ start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
||||
{ start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] },
|
||||
]
|
||||
debuggers = ["CodeLLDB", "GDB"]
|
||||
block_comment = { start = "/*", prefix = "", end = "*/", tab_size = 1 }
|
||||
documentation_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 }
|
||||
156
crates/grammars/src/c/highlights.scm
Normal file
156
crates/grammars/src/c/highlights.scm
Normal file
@@ -0,0 +1,156 @@
|
||||
[
|
||||
"const"
|
||||
"enum"
|
||||
"extern"
|
||||
"inline"
|
||||
"sizeof"
|
||||
"static"
|
||||
"struct"
|
||||
"typedef"
|
||||
"union"
|
||||
"volatile"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"break"
|
||||
"case"
|
||||
"continue"
|
||||
"default"
|
||||
"do"
|
||||
"else"
|
||||
"for"
|
||||
"goto"
|
||||
"if"
|
||||
"return"
|
||||
"switch"
|
||||
"while"
|
||||
] @keyword.control
|
||||
|
||||
[
|
||||
"#define"
|
||||
"#elif"
|
||||
"#elifdef"
|
||||
"#elifndef"
|
||||
"#else"
|
||||
"#endif"
|
||||
"#if"
|
||||
"#ifdef"
|
||||
"#ifndef"
|
||||
"#include"
|
||||
(preproc_directive)
|
||||
] @keyword.preproc @preproc
|
||||
|
||||
[
|
||||
"="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"&="
|
||||
"|="
|
||||
"^="
|
||||
"<<="
|
||||
">>="
|
||||
"++"
|
||||
"--"
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"~"
|
||||
"&"
|
||||
"|"
|
||||
"^"
|
||||
"<<"
|
||||
">>"
|
||||
"!"
|
||||
"&&"
|
||||
"||"
|
||||
"=="
|
||||
"!="
|
||||
"<"
|
||||
">"
|
||||
"<="
|
||||
">="
|
||||
"->"
|
||||
"?"
|
||||
":"
|
||||
] @operator
|
||||
|
||||
[
|
||||
"."
|
||||
";"
|
||||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
(string_literal)
|
||||
(system_lib_string)
|
||||
(char_literal)
|
||||
] @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(number_literal) @number
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(null) @constant.builtin
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
((identifier) @constant
|
||||
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
|
||||
|
||||
(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)
|
||||
(primitive_type)
|
||||
(sized_type_specifier)
|
||||
] @type
|
||||
|
||||
; GNU __attribute__
|
||||
(attribute_specifier) @attribute
|
||||
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(identifier) @attribute))
|
||||
|
||||
; C23 [[attributes]]
|
||||
(attribute
|
||||
prefix: (identifier) @attribute)
|
||||
|
||||
(attribute
|
||||
name: (identifier) @attribute)
|
||||
33
crates/grammars/src/c/indents.scm
Normal file
33
crates/grammars/src/c/indents.scm
Normal file
@@ -0,0 +1,33 @@
|
||||
[
|
||||
(field_expression)
|
||||
(assignment_expression)
|
||||
(init_declarator)
|
||||
(if_statement)
|
||||
(for_statement)
|
||||
(while_statement)
|
||||
(do_statement)
|
||||
(else_clause)
|
||||
] @indent
|
||||
|
||||
(_
|
||||
"{"
|
||||
"}" @end) @indent
|
||||
|
||||
(_
|
||||
"("
|
||||
")" @end) @indent
|
||||
|
||||
((comment) @indent
|
||||
(#match? @indent "^/\\*"))
|
||||
|
||||
(if_statement) @start.if
|
||||
|
||||
(for_statement) @start.for
|
||||
|
||||
(while_statement) @start.while
|
||||
|
||||
(do_statement) @start.do
|
||||
|
||||
(switch_statement) @start.switch
|
||||
|
||||
(else_clause) @start.else
|
||||
15
crates/grammars/src/c/injections.scm
Normal file
15
crates/grammars/src/c/injections.scm
Normal file
@@ -0,0 +1,15 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#match? @injection.content "^(///|//!|/\\*\\*|/\\*!)(.*)")
|
||||
(#set! injection.language "doxygen")
|
||||
(#set! injection.include-children))
|
||||
|
||||
(preproc_def
|
||||
value: (preproc_arg) @injection.content
|
||||
(#set! injection.language "c"))
|
||||
|
||||
(preproc_function_def
|
||||
value: (preproc_arg) @injection.content
|
||||
(#set! injection.language "c"))
|
||||
89
crates/grammars/src/c/outline.scm
Normal file
89
crates/grammars/src/c/outline.scm
Normal file
@@ -0,0 +1,89 @@
|
||||
(preproc_def
|
||||
"#define" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(preproc_function_def
|
||||
"#define" @context
|
||||
name: (_) @name
|
||||
parameters: (preproc_params
|
||||
"(" @context
|
||||
")" @context)) @item
|
||||
|
||||
(struct_specifier
|
||||
"struct" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(union_specifier
|
||||
"union" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(enum_specifier
|
||||
"enum" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(enumerator
|
||||
name: (_) @name) @item
|
||||
|
||||
(field_declaration
|
||||
type: (_) @context
|
||||
declarator: (field_identifier) @name) @item
|
||||
|
||||
(type_definition
|
||||
"typedef" @context
|
||||
declarator: (_) @name) @item
|
||||
|
||||
(declaration
|
||||
(type_qualifier)? @context
|
||||
type: (_)? @context
|
||||
declarator: [
|
||||
(function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context)))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))))
|
||||
]) @item
|
||||
|
||||
(function_definition
|
||||
(type_qualifier)? @context
|
||||
type: (_)? @context
|
||||
declarator: [
|
||||
(function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context)))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))))
|
||||
]) @item
|
||||
|
||||
(comment) @annotation
|
||||
3
crates/grammars/src/c/overrides.scm
Normal file
3
crates/grammars/src/c/overrides.scm
Normal file
@@ -0,0 +1,3 @@
|
||||
(comment) @comment.inclusive
|
||||
|
||||
(string_literal) @string
|
||||
6
crates/grammars/src/c/runnables.scm
Normal file
6
crates/grammars/src/c/runnables.scm
Normal file
@@ -0,0 +1,6 @@
|
||||
; Tag the main function
|
||||
((function_definition
|
||||
declarator: (function_declarator
|
||||
declarator: (identifier) @run)) @_c-main
|
||||
(#eq? @run "main")
|
||||
(#set! tag c-main))
|
||||
34
crates/grammars/src/c/textobjects.scm
Normal file
34
crates/grammars/src/c/textobjects.scm
Normal file
@@ -0,0 +1,34 @@
|
||||
(declaration
|
||||
declarator: (function_declarator)) @function.around
|
||||
|
||||
(function_definition
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
(preproc_function_def
|
||||
value: (_) @function.inside) @function.around
|
||||
|
||||
(comment) @comment.around
|
||||
|
||||
(struct_specifier
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(enum_specifier
|
||||
body: (_
|
||||
"{"
|
||||
[
|
||||
(_)
|
||||
","?
|
||||
]* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(union_specifier
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @class.inside
|
||||
"}")) @class.around
|
||||
19
crates/grammars/src/cpp/brackets.scm
Normal file
19
crates/grammars/src/cpp/brackets.scm
Normal file
@@ -0,0 +1,19 @@
|
||||
("(" @open
|
||||
")" @close)
|
||||
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
|
||||
("<" @open
|
||||
">" @close)
|
||||
|
||||
(("\"" @open
|
||||
"\"" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("'" @open
|
||||
"'" @close)
|
||||
(#set! rainbow.exclude))
|
||||
22
crates/grammars/src/cpp/config.toml
Normal file
22
crates/grammars/src/cpp/config.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
name = "C++"
|
||||
grammar = "cpp"
|
||||
path_suffixes = ["cc", "ccm", "hh", "cpp", "cppm", "h", "hpp", "cxx", "cxxm", "hxx", "c++", "c++m", "h++", "ipp", "inl", "ino", "ixx", "cu", "cuh", "C", "H"]
|
||||
modeline_aliases = ["c++", "cpp", "cxx"]
|
||||
line_comments = ["// ", "/// ", "//! "]
|
||||
first_line_pattern = '^//.*-\*-\s*C\+\+\s*-\*-'
|
||||
decrease_indent_patterns = [
|
||||
{ pattern = "^\\s*\\{.*\\}?\\s*$", valid_after = ["if", "for", "while", "do", "switch", "else"] },
|
||||
{ pattern = "^\\s*else\\b", valid_after = ["if"] }
|
||||
]
|
||||
autoclose_before = ";:.,=}])>"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
|
||||
{ start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
||||
{ start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] },
|
||||
]
|
||||
debuggers = ["CodeLLDB", "GDB"]
|
||||
block_comment = { start = "/*", prefix = "", end = "*/", tab_size = 1 }
|
||||
documentation_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 }
|
||||
302
crates/grammars/src/cpp/highlights.scm
Normal file
302
crates/grammars/src/cpp/highlights.scm
Normal file
@@ -0,0 +1,302 @@
|
||||
(identifier) @variable
|
||||
|
||||
(field_identifier) @property
|
||||
|
||||
(namespace_identifier) @namespace
|
||||
|
||||
(concept_definition
|
||||
name: (identifier) @concept)
|
||||
|
||||
(requires_clause
|
||||
constraint: (template_type
|
||||
name: (type_identifier) @concept))
|
||||
|
||||
(module_name
|
||||
(identifier) @module)
|
||||
|
||||
(module_declaration
|
||||
name: (module_name
|
||||
(identifier) @module))
|
||||
|
||||
(import_declaration
|
||||
name: (module_name
|
||||
(identifier) @module))
|
||||
|
||||
(import_declaration
|
||||
partition: (module_partition
|
||||
(module_name
|
||||
(identifier) @module)))
|
||||
|
||||
(call_expression
|
||||
function: (qualified_identifier
|
||||
name: (identifier) @function))
|
||||
|
||||
(call_expression
|
||||
(qualified_identifier
|
||||
(identifier) @function.call))
|
||||
|
||||
(call_expression
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(identifier) @function.call)))
|
||||
|
||||
(call_expression
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(identifier) @function.call))))
|
||||
|
||||
((qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(qualified_identifier
|
||||
(identifier) @function.call)))) @_parent
|
||||
(#has-ancestor? @_parent call_expression))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function)
|
||||
|
||||
(call_expression
|
||||
function: (field_expression
|
||||
field: (field_identifier) @function))
|
||||
|
||||
(preproc_function_def
|
||||
name: (identifier) @function.special)
|
||||
|
||||
(template_function
|
||||
name: (identifier) @function)
|
||||
|
||||
(template_method
|
||||
name: (field_identifier) @function)
|
||||
|
||||
(function_declarator
|
||||
declarator: (identifier) @function)
|
||||
|
||||
(function_declarator
|
||||
declarator: (qualified_identifier
|
||||
name: (identifier) @function))
|
||||
|
||||
(function_declarator
|
||||
declarator: (field_identifier) @function)
|
||||
|
||||
(operator_name
|
||||
(identifier)? @operator) @function
|
||||
|
||||
(operator_name
|
||||
"<=>" @operator.spaceship)
|
||||
|
||||
(destructor_name
|
||||
(identifier) @function)
|
||||
|
||||
((namespace_identifier) @type
|
||||
(#match? @type "^[A-Z]"))
|
||||
|
||||
(auto) @type
|
||||
|
||||
(type_identifier) @type
|
||||
|
||||
type: (primitive_type) @type.builtin
|
||||
|
||||
(sized_type_specifier) @type.builtin
|
||||
|
||||
; GNU __attribute__
|
||||
(attribute_specifier) @attribute
|
||||
|
||||
(attribute_specifier
|
||||
(argument_list
|
||||
(identifier) @attribute))
|
||||
|
||||
; C++11 [[attributes]]
|
||||
(attribute
|
||||
prefix: (identifier) @attribute)
|
||||
|
||||
(attribute
|
||||
name: (identifier) @attribute)
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^_*[A-Z][A-Z\\d_]*$"))
|
||||
|
||||
(statement_identifier) @label
|
||||
|
||||
(this) @variable.builtin
|
||||
|
||||
"static_assert" @function.builtin
|
||||
|
||||
[
|
||||
"alignas"
|
||||
"alignof"
|
||||
"class"
|
||||
"concept"
|
||||
"consteval"
|
||||
"constexpr"
|
||||
"constinit"
|
||||
"decltype"
|
||||
"delete"
|
||||
"enum"
|
||||
"explicit"
|
||||
"export"
|
||||
"extern"
|
||||
"final"
|
||||
"friend"
|
||||
"import"
|
||||
"inline"
|
||||
"module"
|
||||
"namespace"
|
||||
"new"
|
||||
"noexcept"
|
||||
"operator"
|
||||
"override"
|
||||
"private"
|
||||
"protected"
|
||||
"public"
|
||||
"requires"
|
||||
"sizeof"
|
||||
"struct"
|
||||
"template"
|
||||
"thread_local"
|
||||
"typedef"
|
||||
"typename"
|
||||
"union"
|
||||
"using"
|
||||
"virtual"
|
||||
(storage_class_specifier)
|
||||
(type_qualifier)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"break"
|
||||
"case"
|
||||
"catch"
|
||||
"co_await"
|
||||
"co_return"
|
||||
"co_yield"
|
||||
"continue"
|
||||
"default"
|
||||
"do"
|
||||
"else"
|
||||
"for"
|
||||
"goto"
|
||||
"if"
|
||||
"return"
|
||||
"switch"
|
||||
"throw"
|
||||
"try"
|
||||
"while"
|
||||
] @keyword.control
|
||||
|
||||
[
|
||||
"#define"
|
||||
"#elif"
|
||||
"#elifdef"
|
||||
"#elifndef"
|
||||
"#else"
|
||||
"#endif"
|
||||
"#if"
|
||||
"#ifdef"
|
||||
"#ifndef"
|
||||
"#include"
|
||||
(preproc_directive)
|
||||
] @keyword.preproc @preproc
|
||||
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
[
|
||||
(null)
|
||||
"nullptr"
|
||||
] @constant.builtin
|
||||
|
||||
(number_literal) @number
|
||||
|
||||
[
|
||||
(string_literal)
|
||||
(system_lib_string)
|
||||
(char_literal)
|
||||
(raw_string_literal)
|
||||
] @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
[
|
||||
","
|
||||
":"
|
||||
"::"
|
||||
";"
|
||||
(raw_string_delimiter)
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"."
|
||||
".*"
|
||||
"->*"
|
||||
"~"
|
||||
"-"
|
||||
"--"
|
||||
"-="
|
||||
"->"
|
||||
"="
|
||||
"!"
|
||||
"!="
|
||||
"|"
|
||||
"|="
|
||||
"||"
|
||||
"^"
|
||||
"^="
|
||||
"&"
|
||||
"&="
|
||||
"&&"
|
||||
"+"
|
||||
"++"
|
||||
"+="
|
||||
"*"
|
||||
"*="
|
||||
"/"
|
||||
"/="
|
||||
"%"
|
||||
"%="
|
||||
"<<"
|
||||
"<<="
|
||||
">>"
|
||||
">>="
|
||||
"<"
|
||||
"=="
|
||||
">"
|
||||
"<="
|
||||
">="
|
||||
"?"
|
||||
"and"
|
||||
"and_eq"
|
||||
"bitand"
|
||||
"bitor"
|
||||
"compl"
|
||||
"not"
|
||||
"not_eq"
|
||||
"or"
|
||||
"or_eq"
|
||||
"xor"
|
||||
"xor_eq"
|
||||
] @operator
|
||||
|
||||
"<=>" @operator.spaceship
|
||||
|
||||
(binary_expression
|
||||
operator: "<=>" @operator.spaceship)
|
||||
|
||||
(conditional_expression
|
||||
":" @operator)
|
||||
|
||||
(user_defined_literal
|
||||
(literal_suffix) @operator)
|
||||
41
crates/grammars/src/cpp/indents.scm
Normal file
41
crates/grammars/src/cpp/indents.scm
Normal file
@@ -0,0 +1,41 @@
|
||||
[
|
||||
(field_expression)
|
||||
(assignment_expression)
|
||||
(init_declarator)
|
||||
(if_statement)
|
||||
(for_statement)
|
||||
(while_statement)
|
||||
(do_statement)
|
||||
(else_clause)
|
||||
] @indent
|
||||
|
||||
(_
|
||||
"{"
|
||||
"}" @end) @indent
|
||||
|
||||
(field_declaration_list
|
||||
(access_specifier) @start
|
||||
"}" @end) @indent
|
||||
|
||||
(field_declaration_list
|
||||
(access_specifier)
|
||||
(access_specifier) @outdent)
|
||||
|
||||
(_
|
||||
"("
|
||||
")" @end) @indent
|
||||
|
||||
((comment) @indent
|
||||
(#match? @indent "^/\\*"))
|
||||
|
||||
(if_statement) @start.if
|
||||
|
||||
(for_statement) @start.for
|
||||
|
||||
(while_statement) @start.while
|
||||
|
||||
(do_statement) @start.do
|
||||
|
||||
(switch_statement) @start.switch
|
||||
|
||||
(else_clause) @start.else
|
||||
19
crates/grammars/src/cpp/injections.scm
Normal file
19
crates/grammars/src/cpp/injections.scm
Normal file
@@ -0,0 +1,19 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#match? @injection.content "^(///|//!|/\\*\\*|/\\*!)(.*)")
|
||||
(#set! injection.language "doxygen")
|
||||
(#set! injection.include-children))
|
||||
|
||||
(preproc_def
|
||||
value: (preproc_arg) @injection.content
|
||||
(#set! injection.language "c++"))
|
||||
|
||||
(preproc_function_def
|
||||
value: (preproc_arg) @injection.content
|
||||
(#set! injection.language "c++"))
|
||||
|
||||
(raw_string_literal
|
||||
delimiter: (raw_string_delimiter) @injection.language
|
||||
(raw_string_content) @injection.content)
|
||||
195
crates/grammars/src/cpp/outline.scm
Normal file
195
crates/grammars/src/cpp/outline.scm
Normal file
@@ -0,0 +1,195 @@
|
||||
(preproc_def
|
||||
"#define" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(preproc_function_def
|
||||
"#define" @context
|
||||
name: (_) @name
|
||||
parameters: (preproc_params
|
||||
"(" @context
|
||||
")" @context)) @item
|
||||
|
||||
(namespace_definition
|
||||
"inline"? @context
|
||||
"namespace" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(type_definition
|
||||
"typedef" @context
|
||||
declarator: (_) @name) @item
|
||||
|
||||
(struct_specifier
|
||||
"struct" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(class_specifier
|
||||
"class" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(enum_specifier
|
||||
"enum" @context
|
||||
[
|
||||
"class"
|
||||
"struct"
|
||||
]? @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(union_specifier
|
||||
"union" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(enumerator
|
||||
name: (_) @name) @item
|
||||
|
||||
(concept_definition
|
||||
"concept" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(declaration
|
||||
[
|
||||
(storage_class_specifier)
|
||||
(type_qualifier)
|
||||
]* @context
|
||||
type: (_) @context
|
||||
declarator: [
|
||||
; The declaration may define multiple variables, using @item on the
|
||||
; declarator so that they get distinct ranges.
|
||||
(init_declarator
|
||||
declarator: (_) @item @name)
|
||||
(identifier) @item @name
|
||||
] @item)
|
||||
|
||||
(function_definition
|
||||
[
|
||||
(storage_class_specifier)
|
||||
(type_qualifier)
|
||||
]* @context
|
||||
type: (_)? @context
|
||||
declarator: [
|
||||
(function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context)))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))))
|
||||
(reference_declarator
|
||||
[
|
||||
"&"
|
||||
"&&"
|
||||
] @context
|
||||
(function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context)))
|
||||
]
|
||||
(type_qualifier)? @context) @item
|
||||
|
||||
(declaration
|
||||
[
|
||||
(storage_class_specifier)
|
||||
(type_qualifier)
|
||||
]* @context
|
||||
type: (_)? @context
|
||||
declarator: [
|
||||
(field_identifier) @name
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (field_identifier) @name)
|
||||
(function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context)))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))))
|
||||
(reference_declarator
|
||||
[
|
||||
"&"
|
||||
"&&"
|
||||
] @context
|
||||
(function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context)))
|
||||
]
|
||||
(type_qualifier)? @context) @item
|
||||
|
||||
(field_declaration
|
||||
[
|
||||
(storage_class_specifier)
|
||||
(type_qualifier)
|
||||
]* @context
|
||||
type: (_) @context
|
||||
declarator: [
|
||||
(field_identifier) @name
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (field_identifier) @name)
|
||||
(function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context)))
|
||||
(pointer_declarator
|
||||
"*" @context
|
||||
declarator: (pointer_declarator
|
||||
"*" @context
|
||||
declarator: (function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context))))
|
||||
(reference_declarator
|
||||
[
|
||||
"&"
|
||||
"&&"
|
||||
] @context
|
||||
(function_declarator
|
||||
declarator: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context)))
|
||||
; Fields declarations may define multiple fields, and so @item is on the
|
||||
; declarator so they each get distinct ranges.
|
||||
] @item
|
||||
(type_qualifier)? @context)
|
||||
|
||||
(comment) @annotation
|
||||
3
crates/grammars/src/cpp/overrides.scm
Normal file
3
crates/grammars/src/cpp/overrides.scm
Normal file
@@ -0,0 +1,3 @@
|
||||
(comment) @comment.inclusive
|
||||
|
||||
(string_literal) @string
|
||||
7
crates/grammars/src/cpp/semantic_token_rules.json
Normal file
7
crates/grammars/src/cpp/semantic_token_rules.json
Normal file
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"token_type": "variable",
|
||||
"token_modifiers": ["readonly"],
|
||||
"style": ["constant"]
|
||||
}
|
||||
]
|
||||
44
crates/grammars/src/cpp/textobjects.scm
Normal file
44
crates/grammars/src/cpp/textobjects.scm
Normal file
@@ -0,0 +1,44 @@
|
||||
(declaration
|
||||
declarator: (function_declarator)) @function.around
|
||||
|
||||
(function_definition
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
(preproc_function_def
|
||||
value: (_) @function.inside) @function.around
|
||||
|
||||
(comment) @comment.around
|
||||
|
||||
(struct_specifier
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(enum_specifier
|
||||
body: (_
|
||||
"{"
|
||||
[
|
||||
(_)
|
||||
","?
|
||||
]* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(union_specifier
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(class_specifier
|
||||
body: (_
|
||||
"{"
|
||||
[
|
||||
(_)
|
||||
":"?
|
||||
";"?
|
||||
]* @class.inside
|
||||
"}"?)) @class.around
|
||||
16
crates/grammars/src/css/brackets.scm
Normal file
16
crates/grammars/src/css/brackets.scm
Normal file
@@ -0,0 +1,16 @@
|
||||
("(" @open
|
||||
")" @close)
|
||||
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
|
||||
(("\"" @open
|
||||
"\"" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("'" @open
|
||||
"'" @close)
|
||||
(#set! rainbow.exclude))
|
||||
15
crates/grammars/src/css/config.toml
Normal file
15
crates/grammars/src/css/config.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
name = "CSS"
|
||||
grammar = "css"
|
||||
path_suffixes = ["css", "postcss", "pcss"]
|
||||
autoclose_before = ";:.,=}])>"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] },
|
||||
{ start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
|
||||
]
|
||||
completion_query_characters = ["-", "@"]
|
||||
block_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 }
|
||||
prettier_parser_name = "css"
|
||||
word_characters = ["#"]
|
||||
119
crates/grammars/src/css/highlights.scm
Normal file
119
crates/grammars/src/css/highlights.scm
Normal file
@@ -0,0 +1,119 @@
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
(tag_name)
|
||||
(nesting_selector)
|
||||
(universal_selector)
|
||||
] @tag
|
||||
|
||||
[
|
||||
"~"
|
||||
">"
|
||||
"+"
|
||||
"-"
|
||||
"|"
|
||||
"*"
|
||||
"/"
|
||||
"="
|
||||
"^="
|
||||
"|="
|
||||
"~="
|
||||
"$="
|
||||
"*="
|
||||
] @operator
|
||||
|
||||
[
|
||||
"and"
|
||||
"or"
|
||||
"not"
|
||||
"only"
|
||||
] @keyword.operator
|
||||
|
||||
(id_name) @selector.id
|
||||
|
||||
(class_name) @selector.class
|
||||
|
||||
(namespace_name) @namespace
|
||||
|
||||
(namespace_selector
|
||||
(tag_name) @namespace
|
||||
"|")
|
||||
|
||||
(attribute_name) @attribute
|
||||
|
||||
(pseudo_element_selector
|
||||
"::"
|
||||
(tag_name) @selector.pseudo)
|
||||
|
||||
(pseudo_class_selector
|
||||
":"
|
||||
(class_name) @selector.pseudo)
|
||||
|
||||
[
|
||||
(feature_name)
|
||||
(property_name)
|
||||
] @property
|
||||
|
||||
(function_name) @function
|
||||
|
||||
[
|
||||
(plain_value)
|
||||
(keyframes_name)
|
||||
(keyword_query)
|
||||
] @constant.builtin
|
||||
|
||||
(attribute_selector
|
||||
(plain_value) @string)
|
||||
|
||||
(parenthesized_query
|
||||
(keyword_query) @property)
|
||||
|
||||
([
|
||||
(property_name)
|
||||
(plain_value)
|
||||
] @variable
|
||||
(#match? @variable "^--"))
|
||||
|
||||
[
|
||||
"@media"
|
||||
"@import"
|
||||
"@charset"
|
||||
"@namespace"
|
||||
"@supports"
|
||||
"@keyframes"
|
||||
(at_keyword)
|
||||
(to)
|
||||
(from)
|
||||
(important)
|
||||
] @keyword
|
||||
|
||||
(string_value) @string
|
||||
|
||||
(color_value) @string.special
|
||||
|
||||
[
|
||||
(integer_value)
|
||||
(float_value)
|
||||
] @number
|
||||
|
||||
(unit) @type.unit
|
||||
|
||||
[
|
||||
","
|
||||
":"
|
||||
"."
|
||||
"::"
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
(id_selector
|
||||
"#" @punctuation.delimiter)
|
||||
|
||||
[
|
||||
"{"
|
||||
")"
|
||||
"("
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
3
crates/grammars/src/css/indents.scm
Normal file
3
crates/grammars/src/css/indents.scm
Normal file
@@ -0,0 +1,3 @@
|
||||
(_
|
||||
"{"
|
||||
"}" @end) @indent
|
||||
2
crates/grammars/src/css/injections.scm
Normal file
2
crates/grammars/src/css/injections.scm
Normal file
@@ -0,0 +1,2 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
16
crates/grammars/src/css/outline.scm
Normal file
16
crates/grammars/src/css/outline.scm
Normal file
@@ -0,0 +1,16 @@
|
||||
(stylesheet
|
||||
(import_statement
|
||||
"@import" @context
|
||||
(string_value) @name) @item)
|
||||
|
||||
(rule_set
|
||||
(selectors
|
||||
.
|
||||
(_) @name
|
||||
("," @name
|
||||
(_) @name)*)) @item
|
||||
|
||||
(media_statement
|
||||
"@media" @context
|
||||
(_) @name
|
||||
(block)) @item
|
||||
3
crates/grammars/src/css/overrides.scm
Normal file
3
crates/grammars/src/css/overrides.scm
Normal file
@@ -0,0 +1,3 @@
|
||||
(comment) @comment.inclusive
|
||||
|
||||
(string_value) @string
|
||||
31
crates/grammars/src/css/textobjects.scm
Normal file
31
crates/grammars/src/css/textobjects.scm
Normal file
@@ -0,0 +1,31 @@
|
||||
(comment) @comment.around
|
||||
|
||||
(rule_set
|
||||
(block
|
||||
("{"
|
||||
(_)* @function.inside
|
||||
"}"))) @function.around
|
||||
|
||||
(keyframe_block
|
||||
(block
|
||||
("{"
|
||||
(_)* @function.inside
|
||||
"}"))) @function.around
|
||||
|
||||
(media_statement
|
||||
(block
|
||||
("{"
|
||||
(_)* @class.inside
|
||||
"}"))) @class.around
|
||||
|
||||
(supports_statement
|
||||
(block
|
||||
("{"
|
||||
(_)* @class.inside
|
||||
"}"))) @class.around
|
||||
|
||||
(keyframes_statement
|
||||
(keyframe_block_list
|
||||
("{"
|
||||
(_)* @class.inside
|
||||
"}"))) @class.around
|
||||
4
crates/grammars/src/diff/config.toml
Normal file
4
crates/grammars/src/diff/config.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
name = "Diff"
|
||||
grammar = "diff"
|
||||
path_suffixes = ["diff", "patch"]
|
||||
brackets = []
|
||||
46
crates/grammars/src/diff/highlights.scm
Normal file
46
crates/grammars/src/diff/highlights.scm
Normal file
@@ -0,0 +1,46 @@
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
(addition)
|
||||
(new_file)
|
||||
] @string @diff.plus
|
||||
|
||||
[
|
||||
(deletion)
|
||||
(old_file)
|
||||
] @keyword @diff.minus
|
||||
|
||||
(commit) @constant
|
||||
|
||||
(location) @attribute
|
||||
|
||||
(command
|
||||
"diff" @function
|
||||
(argument) @variable.parameter)
|
||||
|
||||
(mode) @number
|
||||
|
||||
[
|
||||
".."
|
||||
"+"
|
||||
"++"
|
||||
"+++"
|
||||
"++++"
|
||||
"-"
|
||||
"--"
|
||||
"---"
|
||||
"----"
|
||||
] @punctuation.special
|
||||
|
||||
[
|
||||
(binary_change)
|
||||
(similarity)
|
||||
(file_change)
|
||||
] @label
|
||||
|
||||
(index
|
||||
"index" @keyword)
|
||||
|
||||
(similarity
|
||||
(score) @number
|
||||
"%" @number)
|
||||
2
crates/grammars/src/diff/injections.scm
Normal file
2
crates/grammars/src/diff/injections.scm
Normal file
@@ -0,0 +1,2 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
24
crates/grammars/src/gitcommit/config.toml
Normal file
24
crates/grammars/src/gitcommit/config.toml
Normal file
@@ -0,0 +1,24 @@
|
||||
name = "Git Commit"
|
||||
grammar = "gitcommit"
|
||||
path_suffixes = [
|
||||
"TAG_EDITMSG",
|
||||
"MERGE_MSG",
|
||||
"COMMIT_EDITMSG",
|
||||
"NOTES_EDITMSG",
|
||||
"EDIT_DESCRIPTION",
|
||||
]
|
||||
line_comments = ["# "]
|
||||
brackets = [
|
||||
{ start = "(", end = ")", close = true, newline = false },
|
||||
{ start = "`", end = "`", close = true, newline = false },
|
||||
{ start = "\"", end = "\"", close = true, newline = false },
|
||||
{ start = "'", end = "'", close = true, newline = false },
|
||||
{ start = "{", end = "}", close = true, newline = false },
|
||||
{ start = "[", end = "]", close = true, newline = false },
|
||||
]
|
||||
rewrap_prefixes = [
|
||||
"[-*+]\\s+",
|
||||
"\\d+\\.\\s+",
|
||||
">\\s*",
|
||||
"[-*+]\\s+\\[[\\sx]\\]\\s+"
|
||||
]
|
||||
36
crates/grammars/src/gitcommit/highlights.scm
Normal file
36
crates/grammars/src/gitcommit/highlights.scm
Normal file
@@ -0,0 +1,36 @@
|
||||
(subject) @markup.heading
|
||||
|
||||
(path) @string.special.path
|
||||
|
||||
(branch) @string.special.symbol
|
||||
|
||||
(commit) @constant
|
||||
|
||||
(item) @markup.link.url
|
||||
|
||||
(header) @tag
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(change
|
||||
kind: "new file" @diff.plus)
|
||||
|
||||
(change
|
||||
kind: "deleted" @diff.minus)
|
||||
|
||||
(change
|
||||
kind: "modified" @diff.delta)
|
||||
|
||||
(change
|
||||
kind: "renamed" @diff.delta.moved)
|
||||
|
||||
(trailer
|
||||
key: (trailer_key) @variable.other.member
|
||||
value: (trailer_value) @string)
|
||||
|
||||
[
|
||||
":"
|
||||
"="
|
||||
"->"
|
||||
(scissors)
|
||||
] @punctuation.delimiter
|
||||
8
crates/grammars/src/gitcommit/injections.scm
Normal file
8
crates/grammars/src/gitcommit/injections.scm
Normal file
@@ -0,0 +1,8 @@
|
||||
((comment) @content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((scissors) @content
|
||||
(#set! "language" "diff"))
|
||||
|
||||
((rebase_command) @content
|
||||
(#set! "language" "git_rebase"))
|
||||
19
crates/grammars/src/go/brackets.scm
Normal file
19
crates/grammars/src/go/brackets.scm
Normal file
@@ -0,0 +1,19 @@
|
||||
("(" @open
|
||||
")" @close)
|
||||
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
|
||||
(("\"" @open
|
||||
"\"" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("`" @open
|
||||
"`" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
((rune_literal) @open @close
|
||||
(#set! rainbow.exclude))
|
||||
21
crates/grammars/src/go/config.toml
Normal file
21
crates/grammars/src/go/config.toml
Normal file
@@ -0,0 +1,21 @@
|
||||
name = "Go"
|
||||
grammar = "go"
|
||||
path_suffixes = ["go"]
|
||||
modeline_aliases = ["golang"]
|
||||
line_comments = ["// "]
|
||||
first_line_pattern = '^//.*\bgo run\b'
|
||||
autoclose_before = ";:.,=}])>"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] },
|
||||
{ start = "'", end = "'", close = true, newline = false, not_in = ["comment", "string"] },
|
||||
{ start = "`", end = "`", close = true, newline = false, not_in = ["comment", "string"] },
|
||||
{ start = "/*", end = " */", close = true, newline = false, not_in = ["comment", "string"] },
|
||||
]
|
||||
tab_size = 4
|
||||
hard_tabs = true
|
||||
debuggers = ["Delve"]
|
||||
block_comment = { start = "/*", prefix = "", end = "*/", tab_size = 1 }
|
||||
documentation_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 }
|
||||
44
crates/grammars/src/go/debugger.scm
Normal file
44
crates/grammars/src/go/debugger.scm
Normal file
@@ -0,0 +1,44 @@
|
||||
(parameter_declaration
|
||||
(identifier) @debug-variable)
|
||||
|
||||
(short_var_declaration
|
||||
(expression_list
|
||||
(identifier) @debug-variable))
|
||||
|
||||
(var_declaration
|
||||
(var_spec
|
||||
(identifier) @debug-variable))
|
||||
|
||||
(const_declaration
|
||||
(const_spec
|
||||
(identifier) @debug-variable))
|
||||
|
||||
(assignment_statement
|
||||
(expression_list
|
||||
(identifier) @debug-variable))
|
||||
|
||||
(binary_expression
|
||||
(identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(call_expression
|
||||
(argument_list
|
||||
(identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]")))
|
||||
|
||||
(return_statement
|
||||
(expression_list
|
||||
(identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]")))
|
||||
|
||||
(range_clause
|
||||
(expression_list
|
||||
(identifier) @debug-variable))
|
||||
|
||||
(parenthesized_expression
|
||||
(identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(block) @debug-scope
|
||||
|
||||
(function_declaration) @debug-scope
|
||||
153
crates/grammars/src/go/highlights.scm
Normal file
153
crates/grammars/src/go/highlights.scm
Normal file
@@ -0,0 +1,153 @@
|
||||
(identifier) @variable
|
||||
|
||||
(type_identifier) @type
|
||||
|
||||
(type_spec
|
||||
name: (type_identifier) @type.definition)
|
||||
|
||||
(field_identifier) @property
|
||||
|
||||
(package_identifier) @namespace
|
||||
|
||||
(label_name) @label
|
||||
|
||||
(keyed_element
|
||||
.
|
||||
(literal_element
|
||||
(identifier) @property))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
(call_expression
|
||||
function: (selector_expression
|
||||
field: (field_identifier) @function.method.call))
|
||||
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
(method_declaration
|
||||
name: (field_identifier) @function.method)
|
||||
|
||||
(method_elem
|
||||
name: (field_identifier) @function.method)
|
||||
|
||||
[
|
||||
";"
|
||||
"."
|
||||
","
|
||||
":"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
"--"
|
||||
"-"
|
||||
"-="
|
||||
":="
|
||||
"!"
|
||||
"!="
|
||||
"..."
|
||||
"*"
|
||||
"*"
|
||||
"*="
|
||||
"/"
|
||||
"/="
|
||||
"&"
|
||||
"&&"
|
||||
"&="
|
||||
"%"
|
||||
"%="
|
||||
"^"
|
||||
"^="
|
||||
"+"
|
||||
"++"
|
||||
"+="
|
||||
"<-"
|
||||
"<"
|
||||
"<<"
|
||||
"<<="
|
||||
"<="
|
||||
"="
|
||||
"=="
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
">>="
|
||||
"|"
|
||||
"|="
|
||||
"||"
|
||||
"~"
|
||||
] @operator
|
||||
|
||||
[
|
||||
"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
|
||||
|
||||
[
|
||||
(interpreted_string_literal)
|
||||
(raw_string_literal)
|
||||
(rune_literal)
|
||||
] @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
[
|
||||
(int_literal)
|
||||
(float_literal)
|
||||
(imaginary_literal)
|
||||
] @number
|
||||
|
||||
(const_spec
|
||||
name: (identifier) @constant)
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
[
|
||||
(nil)
|
||||
(iota)
|
||||
] @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; Go directives
|
||||
((comment) @preproc
|
||||
(#match? @preproc "^//go:"))
|
||||
|
||||
((comment) @preproc
|
||||
(#match? @preproc "^// \\+build"))
|
||||
17
crates/grammars/src/go/indents.scm
Normal file
17
crates/grammars/src/go/indents.scm
Normal file
@@ -0,0 +1,17 @@
|
||||
[
|
||||
(assignment_statement)
|
||||
(call_expression)
|
||||
(selector_expression)
|
||||
] @indent
|
||||
|
||||
(_
|
||||
"["
|
||||
"]" @end) @indent
|
||||
|
||||
(_
|
||||
"{"
|
||||
"}" @end) @indent
|
||||
|
||||
(_
|
||||
"("
|
||||
")" @end) @indent
|
||||
730
crates/grammars/src/go/injections.scm
Normal file
730
crates/grammars/src/go/injections.scm
Normal file
@@ -0,0 +1,730 @@
|
||||
; Refer to https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/go/injections.scm#L4C1-L16C41
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(call_expression
|
||||
(selector_expression) @_function
|
||||
(#any-of? @_function
|
||||
"regexp.Match" "regexp.MatchReader" "regexp.MatchString" "regexp.Compile" "regexp.CompilePOSIX"
|
||||
"regexp.MustCompile" "regexp.MustCompilePOSIX")
|
||||
(argument_list
|
||||
.
|
||||
[
|
||||
(raw_string_literal)
|
||||
(interpreted_string_literal)
|
||||
] @injection.content
|
||||
(#set! injection.language "regex")))
|
||||
|
||||
; INJECT SQL
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(composite_literal
|
||||
body: (literal_value
|
||||
(keyed_element
|
||||
(comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))))
|
||||
(expression_statement
|
||||
(call_expression
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])))
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*sql\\s*\\*\\/$")
|
||||
(#set! injection.language "sql"))
|
||||
|
||||
; INJECT JSON
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(composite_literal
|
||||
body: (literal_value
|
||||
(keyed_element
|
||||
(comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))))
|
||||
(expression_statement
|
||||
(call_expression
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])))
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*json\\s*\\*\\/")
|
||||
; /* json */ or /*json*/
|
||||
(#set! injection.language "json"))
|
||||
|
||||
; INJECT YAML
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(composite_literal
|
||||
body: (literal_value
|
||||
(keyed_element
|
||||
(comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))))
|
||||
(expression_statement
|
||||
(call_expression
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])))
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*yaml\\s*\\*\\/")
|
||||
; /* yaml */ or /*yaml*/
|
||||
(#set! injection.language "yaml"))
|
||||
|
||||
; INJECT XML
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(composite_literal
|
||||
body: (literal_value
|
||||
(keyed_element
|
||||
(comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))))
|
||||
(expression_statement
|
||||
(call_expression
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])))
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*xml\\s*\\*\\/")
|
||||
; /* xml */ or /*xml*/
|
||||
(#set! injection.language "xml"))
|
||||
|
||||
; INJECT HTML
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(composite_literal
|
||||
body: (literal_value
|
||||
(keyed_element
|
||||
(comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))))
|
||||
(expression_statement
|
||||
(call_expression
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])))
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*html\\s*\\*\\/")
|
||||
; /* html */ or /*html*/
|
||||
(#set! injection.language "html"))
|
||||
|
||||
; INJECT JS
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(composite_literal
|
||||
body: (literal_value
|
||||
(keyed_element
|
||||
(comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))))
|
||||
(expression_statement
|
||||
(call_expression
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])))
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*js\\s*\\*\\/")
|
||||
; /* js */ or /*js*/
|
||||
(#set! injection.language "javascript"))
|
||||
|
||||
; INJECT CSS
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(composite_literal
|
||||
body: (literal_value
|
||||
(keyed_element
|
||||
(comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))))
|
||||
(expression_statement
|
||||
(call_expression
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])))
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*css\\s*\\*\\/")
|
||||
; /* css */ or /*css*/
|
||||
(#set! injection.language "css"))
|
||||
|
||||
; INJECT LUA
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(composite_literal
|
||||
body: (literal_value
|
||||
(keyed_element
|
||||
(comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))))
|
||||
(expression_statement
|
||||
(call_expression
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])))
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*lua\\s*\\*\\/")
|
||||
; /* lua */ or /*lua*/
|
||||
(#set! injection.language "lua"))
|
||||
|
||||
; INJECT BASH
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(composite_literal
|
||||
body: (literal_value
|
||||
(keyed_element
|
||||
(comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))))
|
||||
(expression_statement
|
||||
(call_expression
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])))
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*bash\\s*\\*\\/")
|
||||
; /* bash */ or /*bash*/
|
||||
(#set! injection.language "bash"))
|
||||
|
||||
; INJECT CSV
|
||||
([
|
||||
(const_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(var_spec
|
||||
name: (identifier)
|
||||
"="
|
||||
(comment) @_comment
|
||||
value: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(assignment_statement
|
||||
left: (expression_list)
|
||||
"="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(short_var_declaration
|
||||
left: (expression_list)
|
||||
":="
|
||||
(comment) @_comment
|
||||
right: (expression_list
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
((comment) @_comment
|
||||
value: (literal_element
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
]))
|
||||
(argument_list
|
||||
(comment) @_comment
|
||||
[
|
||||
(interpreted_string_literal
|
||||
(interpreted_string_literal_content) @injection.content)
|
||||
(raw_string_literal
|
||||
(raw_string_literal_content) @injection.content)
|
||||
])
|
||||
]
|
||||
(#match? @_comment "^\\/\\*\\s*csv\\s*\\*\\/")
|
||||
; /* csv */ or /*csv */
|
||||
(#set! injection.language "csv"))
|
||||
61
crates/grammars/src/go/outline.scm
Normal file
61
crates/grammars/src/go/outline.scm
Normal file
@@ -0,0 +1,61 @@
|
||||
(comment) @annotation
|
||||
|
||||
(type_declaration
|
||||
"type" @context
|
||||
[
|
||||
(type_spec
|
||||
name: (_) @name) @item
|
||||
("("
|
||||
(type_spec
|
||||
name: (_) @name) @item
|
||||
")")
|
||||
])
|
||||
|
||||
(function_declaration
|
||||
"func" @context
|
||||
name: (identifier) @name
|
||||
parameters: (parameter_list
|
||||
"("
|
||||
")")) @item
|
||||
|
||||
(method_declaration
|
||||
"func" @context
|
||||
receiver: (parameter_list
|
||||
"(" @context
|
||||
(parameter_declaration
|
||||
name: (_) @context
|
||||
type: (_) @context)
|
||||
")" @context)
|
||||
name: (field_identifier) @name
|
||||
parameters: (parameter_list
|
||||
"("
|
||||
")")) @item
|
||||
|
||||
(const_declaration
|
||||
"const" @context
|
||||
(const_spec
|
||||
name: (identifier) @name) @item)
|
||||
|
||||
(source_file
|
||||
(var_declaration
|
||||
"var" @context
|
||||
[
|
||||
; The declaration may define multiple variables, and so @item is on
|
||||
; the identifier so they get distinct ranges.
|
||||
(var_spec
|
||||
name: (identifier) @name @item)
|
||||
(var_spec_list
|
||||
(var_spec
|
||||
name: (identifier) @name @item))
|
||||
]))
|
||||
|
||||
(method_elem
|
||||
name: (_) @name
|
||||
parameters: (parameter_list
|
||||
"(" @context
|
||||
")" @context)) @item
|
||||
|
||||
; Fields declarations may define multiple fields, and so @item is on the
|
||||
; declarator so they each get distinct ranges.
|
||||
(field_declaration
|
||||
name: (_) @name @item)
|
||||
7
crates/grammars/src/go/overrides.scm
Normal file
7
crates/grammars/src/go/overrides.scm
Normal file
@@ -0,0 +1,7 @@
|
||||
(comment) @comment.inclusive
|
||||
|
||||
[
|
||||
(interpreted_string_literal)
|
||||
(raw_string_literal)
|
||||
(rune_literal)
|
||||
] @string
|
||||
212
crates/grammars/src/go/runnables.scm
Normal file
212
crates/grammars/src/go/runnables.scm
Normal file
@@ -0,0 +1,212 @@
|
||||
; Functions names start with `Test`
|
||||
(((function_declaration
|
||||
name: (_) @run
|
||||
(#match? @run "^Test.*")
|
||||
(#not-match? @run "^TestMain$"))) @_
|
||||
(#set! tag go-test))
|
||||
|
||||
; Suite test methods (testify/suite)
|
||||
((method_declaration
|
||||
receiver: (parameter_list
|
||||
(parameter_declaration
|
||||
type: [
|
||||
(pointer_type
|
||||
(type_identifier) @_suite_name)
|
||||
(type_identifier) @_suite_name
|
||||
]))
|
||||
name: (field_identifier) @run @_subtest_name
|
||||
(#match? @_subtest_name "^Test.*")
|
||||
(#match? @_suite_name ".*Suite")) @_
|
||||
(#set! tag go-testify-suite))
|
||||
|
||||
; `go:generate` comments
|
||||
(((comment) @_comment @run
|
||||
(#match? @_comment "^//go:generate"))
|
||||
(#set! tag go-generate))
|
||||
|
||||
; `t.Run`
|
||||
(((call_expression
|
||||
function: (selector_expression
|
||||
field: _ @run @_name
|
||||
(#eq? @_name "Run"))
|
||||
arguments: (argument_list
|
||||
.
|
||||
[
|
||||
(interpreted_string_literal)
|
||||
(raw_string_literal)
|
||||
] @_subtest_name
|
||||
.
|
||||
(func_literal
|
||||
parameters: (parameter_list
|
||||
(parameter_declaration
|
||||
name: (identifier) @_param_name
|
||||
type: (pointer_type
|
||||
(qualified_type
|
||||
package: (package_identifier) @_pkg
|
||||
name: (type_identifier) @_type
|
||||
(#eq? @_pkg "testing")
|
||||
(#eq? @_type "T")))))) @_second_argument))) @_
|
||||
(#set! tag go-subtest))
|
||||
|
||||
; Functions names start with `Example`
|
||||
(((function_declaration
|
||||
name: (_) @run @_name
|
||||
(#match? @_name "^Example.*"))) @_
|
||||
(#set! tag go-example))
|
||||
|
||||
; Functions names start with `Benchmark`
|
||||
(((function_declaration
|
||||
name: (_) @run @_name
|
||||
(#match? @_name "^Benchmark.*"))) @_
|
||||
(#set! tag go-benchmark))
|
||||
|
||||
; Functions names start with `Fuzz`
|
||||
(((function_declaration
|
||||
name: (_) @run @_name
|
||||
(#match? @_name "^Fuzz"))) @_
|
||||
(#set! tag go-fuzz))
|
||||
|
||||
; go run
|
||||
(((function_declaration
|
||||
name: (_) @run
|
||||
(#eq? @run "main"))) @_
|
||||
(#set! tag go-main))
|
||||
|
||||
; Table test cases - slice and map with explicit variable
|
||||
((short_var_declaration
|
||||
left: (expression_list
|
||||
(identifier) @_collection_var)
|
||||
right: (expression_list
|
||||
(composite_literal
|
||||
type: [
|
||||
(slice_type)
|
||||
(map_type
|
||||
key: (type_identifier) @_key_type
|
||||
(#eq? @_key_type "string"))
|
||||
]
|
||||
body: (literal_value
|
||||
[
|
||||
(literal_element
|
||||
(literal_value
|
||||
(keyed_element
|
||||
(literal_element
|
||||
(identifier) @_field_name)
|
||||
(literal_element
|
||||
[
|
||||
(interpreted_string_literal) @run @_table_test_case_name
|
||||
(raw_string_literal) @run @_table_test_case_name
|
||||
]))))
|
||||
(keyed_element
|
||||
(literal_element
|
||||
[
|
||||
(interpreted_string_literal) @run @_table_test_case_name
|
||||
(raw_string_literal) @run @_table_test_case_name
|
||||
]))
|
||||
]))))
|
||||
(for_statement
|
||||
(range_clause
|
||||
left: (expression_list
|
||||
[
|
||||
((identifier)
|
||||
(identifier) @_loop_var_inner)
|
||||
(identifier) @_loop_var_outer
|
||||
])
|
||||
right: (identifier) @_range_var
|
||||
(#eq? @_range_var @_collection_var))
|
||||
body: (block
|
||||
(statement_list
|
||||
(expression_statement
|
||||
(call_expression
|
||||
function: (selector_expression
|
||||
operand: (identifier)
|
||||
field: (field_identifier) @_run_method
|
||||
(#eq? @_run_method "Run"))
|
||||
arguments: (argument_list
|
||||
.
|
||||
[
|
||||
(selector_expression
|
||||
operand: (identifier) @_tc_var
|
||||
(#eq? @_tc_var @_loop_var_inner)
|
||||
field: (field_identifier) @_field_check
|
||||
(#eq? @_field_check @_field_name))
|
||||
(identifier) @_arg_var
|
||||
(#eq? @_arg_var @_loop_var_outer)
|
||||
]
|
||||
.
|
||||
(func_literal
|
||||
parameters: (parameter_list
|
||||
(parameter_declaration
|
||||
type: (pointer_type
|
||||
(qualified_type
|
||||
package: (package_identifier) @_pkg
|
||||
name: (type_identifier) @_type
|
||||
(#eq? @_pkg "testing")
|
||||
(#eq? @_type "T")))))))))))) @_
|
||||
(#set! tag go-table-test-case))
|
||||
|
||||
; Table test cases - slice and map declared right inside the loop without
|
||||
; explicit variable
|
||||
((for_statement
|
||||
(range_clause
|
||||
left: (expression_list
|
||||
[
|
||||
((identifier)
|
||||
(identifier) @_loop_var_inner)
|
||||
(identifier) @_loop_var_outer
|
||||
])
|
||||
right: (composite_literal
|
||||
type: [
|
||||
(slice_type)
|
||||
(map_type
|
||||
key: (type_identifier) @_key_type
|
||||
(#eq? @_key_type "string"))
|
||||
]
|
||||
body: (literal_value
|
||||
[
|
||||
(literal_element
|
||||
(literal_value
|
||||
(keyed_element
|
||||
(literal_element
|
||||
(identifier) @_field_name)
|
||||
(literal_element
|
||||
[
|
||||
(interpreted_string_literal) @run @_table_test_case_name
|
||||
(raw_string_literal) @run @_table_test_case_name
|
||||
]))))
|
||||
(keyed_element
|
||||
(literal_element
|
||||
[
|
||||
(interpreted_string_literal) @run @_table_test_case_name
|
||||
(raw_string_literal) @run @_table_test_case_name
|
||||
]))
|
||||
])))
|
||||
body: (block
|
||||
(statement_list
|
||||
(expression_statement
|
||||
(call_expression
|
||||
function: (selector_expression
|
||||
operand: (identifier)
|
||||
field: (field_identifier) @_run_method
|
||||
(#eq? @_run_method "Run"))
|
||||
arguments: (argument_list
|
||||
.
|
||||
[
|
||||
(selector_expression
|
||||
operand: (identifier) @_tc_var
|
||||
(#eq? @_tc_var @_loop_var_inner)
|
||||
field: (field_identifier) @_field_check
|
||||
(#eq? @_field_check @_field_name))
|
||||
(identifier) @_arg_var
|
||||
(#eq? @_arg_var @_loop_var_outer)
|
||||
]
|
||||
.
|
||||
(func_literal
|
||||
parameters: (parameter_list
|
||||
(parameter_declaration
|
||||
type: (pointer_type
|
||||
(qualified_type
|
||||
package: (package_identifier) @_pkg
|
||||
name: (type_identifier) @_type
|
||||
(#eq? @_pkg "testing")
|
||||
(#eq? @_type "T")))))))))))) @_
|
||||
(#set! tag go-table-test-case-without-explicit-variable))
|
||||
12
crates/grammars/src/go/semantic_token_rules.json
Normal file
12
crates/grammars/src/go/semantic_token_rules.json
Normal file
@@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"token_type": "variable",
|
||||
"token_modifiers": ["readonly"],
|
||||
"style": ["constant"]
|
||||
},
|
||||
{
|
||||
"token_type": "string",
|
||||
"token_modifiers": ["format"],
|
||||
"style": ["string.special"]
|
||||
}
|
||||
]
|
||||
28
crates/grammars/src/go/textobjects.scm
Normal file
28
crates/grammars/src/go/textobjects.scm
Normal file
@@ -0,0 +1,28 @@
|
||||
(function_declaration
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
(method_declaration
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
(type_declaration
|
||||
(type_spec
|
||||
(struct_type
|
||||
(field_declaration_list
|
||||
("{"
|
||||
(_)* @class.inside
|
||||
"}")?)))) @class.around
|
||||
|
||||
(type_declaration
|
||||
(type_spec
|
||||
(interface_type
|
||||
(_)* @class.inside))) @class.around
|
||||
|
||||
(type_declaration) @class.around
|
||||
|
||||
(comment)+ @comment.around
|
||||
9
crates/grammars/src/gomod/config.toml
Normal file
9
crates/grammars/src/gomod/config.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
name = "Go Mod"
|
||||
code_fence_block_name = "go.mod"
|
||||
grammar = "gomod"
|
||||
path_suffixes = ["mod"]
|
||||
line_comments = ["// "]
|
||||
autoclose_before = ")"
|
||||
brackets = [
|
||||
{ start = "(", end = ")", close = true, newline = true}
|
||||
]
|
||||
20
crates/grammars/src/gomod/highlights.scm
Normal file
20
crates/grammars/src/gomod/highlights.scm
Normal file
@@ -0,0 +1,20 @@
|
||||
[
|
||||
"require"
|
||||
"replace"
|
||||
"go"
|
||||
"toolchain"
|
||||
"tool"
|
||||
"exclude"
|
||||
"retract"
|
||||
"module"
|
||||
"ignore"
|
||||
] @keyword
|
||||
|
||||
"=>" @operator
|
||||
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
(version)
|
||||
(go_version)
|
||||
] @string
|
||||
2
crates/grammars/src/gomod/injections.scm
Normal file
2
crates/grammars/src/gomod/injections.scm
Normal file
@@ -0,0 +1,2 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
29
crates/grammars/src/gomod/structure.scm
Normal file
29
crates/grammars/src/gomod/structure.scm
Normal file
@@ -0,0 +1,29 @@
|
||||
(require_directive
|
||||
"require" @structure.anchor
|
||||
"(" @structure.open
|
||||
")" @structure.close)
|
||||
|
||||
(exclude_directive
|
||||
"exclude" @structure.anchor
|
||||
"(" @structure.open
|
||||
")" @structure.close)
|
||||
|
||||
(module_directive
|
||||
"module" @structure.anchor
|
||||
"(" @structure.open
|
||||
")" @structure.close)
|
||||
|
||||
(replace_directive
|
||||
"replace" @structure.anchor
|
||||
"(" @structure.open
|
||||
")" @structure.close)
|
||||
|
||||
(retract_directive
|
||||
"retract" @structure.anchor
|
||||
"(" @structure.open
|
||||
")" @structure.close)
|
||||
|
||||
(ignore_directive
|
||||
"ignore" @structure.anchor
|
||||
"(" @structure.open
|
||||
")" @structure.close)
|
||||
9
crates/grammars/src/gowork/config.toml
Normal file
9
crates/grammars/src/gowork/config.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
name = "Go Work"
|
||||
code_fence_block_name = "gowork"
|
||||
grammar = "gowork"
|
||||
path_suffixes = ["work"]
|
||||
line_comments = ["// "]
|
||||
autoclose_before = ")"
|
||||
brackets = [
|
||||
{ start = "(", end = ")", close = true, newline = true}
|
||||
]
|
||||
14
crates/grammars/src/gowork/highlights.scm
Normal file
14
crates/grammars/src/gowork/highlights.scm
Normal file
@@ -0,0 +1,14 @@
|
||||
[
|
||||
"replace"
|
||||
"go"
|
||||
"use"
|
||||
] @keyword
|
||||
|
||||
"=>" @operator
|
||||
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
(version)
|
||||
(go_version)
|
||||
] @string
|
||||
2
crates/grammars/src/gowork/injections.scm
Normal file
2
crates/grammars/src/gowork/injections.scm
Normal file
@@ -0,0 +1,2 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
108
crates/grammars/src/grammars.rs
Normal file
108
crates/grammars/src/grammars.rs
Normal file
@@ -0,0 +1,108 @@
|
||||
use anyhow::Context as _;
|
||||
use language_core::{LanguageConfig, LanguageQueries, QUERY_FILENAME_PREFIXES};
|
||||
use rust_embed::RustEmbed;
|
||||
use util::asset_str;
|
||||
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "src/"]
|
||||
#[exclude = "*.rs"]
|
||||
struct GrammarDir;
|
||||
|
||||
/// Register all built-in native tree-sitter grammars with the provided registration function.
|
||||
///
|
||||
/// Each grammar is registered as a `(&str, tree_sitter_language::LanguageFn)` pair.
|
||||
/// This must be called before loading language configs/queries.
|
||||
#[cfg(feature = "load-grammars")]
|
||||
pub fn native_grammars() -> Vec<(&'static str, tree_sitter::Language)> {
|
||||
vec![
|
||||
("bash", tree_sitter_bash::LANGUAGE.into()),
|
||||
("c", tree_sitter_c::LANGUAGE.into()),
|
||||
("cpp", tree_sitter_cpp::LANGUAGE.into()),
|
||||
("css", tree_sitter_css::LANGUAGE.into()),
|
||||
("diff", tree_sitter_diff::LANGUAGE.into()),
|
||||
("go", tree_sitter_go::LANGUAGE.into()),
|
||||
("gomod", tree_sitter_go_mod::LANGUAGE.into()),
|
||||
("gowork", tree_sitter_gowork::LANGUAGE.into()),
|
||||
("jsdoc", tree_sitter_jsdoc::LANGUAGE.into()),
|
||||
("json", tree_sitter_json::LANGUAGE.into()),
|
||||
("jsonc", tree_sitter_json::LANGUAGE.into()),
|
||||
("markdown", tree_sitter_md::LANGUAGE.into()),
|
||||
("markdown-inline", tree_sitter_md::INLINE_LANGUAGE.into()),
|
||||
("python", tree_sitter_python::LANGUAGE.into()),
|
||||
("regex", tree_sitter_regex::LANGUAGE.into()),
|
||||
("rust", tree_sitter_rust::LANGUAGE.into()),
|
||||
("tsx", tree_sitter_typescript::LANGUAGE_TSX.into()),
|
||||
(
|
||||
"typescript",
|
||||
tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into(),
|
||||
),
|
||||
("yaml", tree_sitter_yaml::LANGUAGE.into()),
|
||||
("gitcommit", tree_sitter_gitcommit::LANGUAGE.into()),
|
||||
]
|
||||
}
|
||||
|
||||
/// Load and parse the `config.toml` for a given language name.
|
||||
pub fn load_config(name: &str) -> LanguageConfig {
|
||||
let config_toml = String::from_utf8(
|
||||
GrammarDir::get(&format!("{}/config.toml", name))
|
||||
.unwrap_or_else(|| panic!("missing config for language {:?}", name))
|
||||
.data
|
||||
.to_vec(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let config: LanguageConfig = ::toml::from_str(&config_toml)
|
||||
.with_context(|| format!("failed to load config.toml for language {name:?}"))
|
||||
.unwrap();
|
||||
|
||||
config
|
||||
}
|
||||
|
||||
/// Load and parse the `config.toml` for a given language name, stripping fields
|
||||
/// that require grammar support when grammars are not loaded.
|
||||
pub fn load_config_for_feature(name: &str, grammars_loaded: bool) -> LanguageConfig {
|
||||
let config = load_config(name);
|
||||
|
||||
if grammars_loaded {
|
||||
config
|
||||
} else {
|
||||
LanguageConfig {
|
||||
name: config.name,
|
||||
matcher: config.matcher,
|
||||
jsx_tag_auto_close: config.jsx_tag_auto_close,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a raw embedded file by path (relative to `src/`).
|
||||
///
|
||||
/// Returns the file data as bytes, or `None` if the file does not exist.
|
||||
pub fn get_file(path: &str) -> Option<rust_embed::EmbeddedFile> {
|
||||
GrammarDir::get(path)
|
||||
}
|
||||
|
||||
/// Load all `.scm` query files for a given language name into a `LanguageQueries`.
|
||||
///
|
||||
/// Multiple `.scm` files with the same prefix (e.g. `highlights.scm` and
|
||||
/// `highlights_extra.scm`) are concatenated together with their contents appended.
|
||||
pub fn load_queries(name: &str) -> LanguageQueries {
|
||||
let mut result = LanguageQueries::default();
|
||||
for path in GrammarDir::iter() {
|
||||
if let Some(remainder) = path.strip_prefix(name).and_then(|p| p.strip_prefix('/')) {
|
||||
if !remainder.ends_with(".scm") {
|
||||
continue;
|
||||
}
|
||||
for (prefix, query) in QUERY_FILENAME_PREFIXES {
|
||||
if remainder.starts_with(prefix) {
|
||||
let contents = asset_str::<GrammarDir>(path.as_ref());
|
||||
match query(&mut result) {
|
||||
None => *query(&mut result) = Some(contents),
|
||||
Some(existing) => existing.to_mut().push_str(contents.as_ref()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
29
crates/grammars/src/javascript/brackets.scm
Normal file
29
crates/grammars/src/javascript/brackets.scm
Normal file
@@ -0,0 +1,29 @@
|
||||
("(" @open
|
||||
")" @close)
|
||||
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
|
||||
("<" @open
|
||||
">" @close)
|
||||
|
||||
("<" @open
|
||||
"/>" @close)
|
||||
|
||||
("</" @open
|
||||
">" @close)
|
||||
|
||||
(("\"" @open
|
||||
"\"" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("'" @open
|
||||
"'" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("`" @open
|
||||
"`" @close)
|
||||
(#set! rainbow.exclude))
|
||||
44
crates/grammars/src/javascript/config.toml
Normal file
44
crates/grammars/src/javascript/config.toml
Normal file
@@ -0,0 +1,44 @@
|
||||
name = "JavaScript"
|
||||
grammar = "tsx"
|
||||
path_suffixes = ["js", "jsx", "mjs", "cjs"]
|
||||
modeline_aliases = ["js", "js2"]
|
||||
# [/ ] is so we match "env node" or "/node" but not "ts-node"
|
||||
first_line_pattern = '^#!.*\b(?:[/ ]node|deno run.*--ext[= ]js)\b'
|
||||
line_comments = ["// "]
|
||||
block_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 }
|
||||
documentation_comment = { start = "/**", prefix = "* ", end = "*/", tab_size = 1 }
|
||||
wrap_characters = { start_prefix = "<", start_suffix = ">", end_prefix = "</", end_suffix = ">" }
|
||||
autoclose_before = ";:.,=}])>"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "<", end = ">", close = false, newline = true, not_in = ["comment", "string"] },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = ["comment", "string"] },
|
||||
{ start = "'", end = "'", close = true, newline = false, not_in = ["comment", "string"] },
|
||||
{ start = "`", end = "`", close = true, newline = false, not_in = ["comment", "string"] },
|
||||
{ start = "/*", end = " */", close = true, newline = false, not_in = ["comment", "string"] },
|
||||
]
|
||||
word_characters = ["$", "#"]
|
||||
tab_size = 2
|
||||
scope_opt_in_language_servers = ["tailwindcss-language-server", "emmet-language-server"]
|
||||
prettier_parser_name = "babel"
|
||||
debuggers = ["JavaScript"]
|
||||
|
||||
[jsx_tag_auto_close]
|
||||
open_tag_node_name = "jsx_opening_element"
|
||||
close_tag_node_name = "jsx_closing_element"
|
||||
jsx_element_node_name = "jsx_element"
|
||||
tag_name_node_name = "identifier"
|
||||
|
||||
[overrides.default]
|
||||
linked_edit_characters = ["."]
|
||||
|
||||
[overrides.element]
|
||||
line_comments = { remove = true }
|
||||
block_comment = { start = "{/* ", prefix = "", end = "*/}", tab_size = 1 }
|
||||
opt_into_language_servers = ["emmet-language-server"]
|
||||
|
||||
[overrides.string]
|
||||
completion_query_characters = ["-", "."]
|
||||
opt_into_language_servers = ["tailwindcss-language-server"]
|
||||
51
crates/grammars/src/javascript/debugger.scm
Normal file
51
crates/grammars/src/javascript/debugger.scm
Normal file
@@ -0,0 +1,51 @@
|
||||
(lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @debug-variable))
|
||||
|
||||
(for_in_statement
|
||||
left: (identifier) @debug-variable)
|
||||
|
||||
(for_statement
|
||||
initializer: (lexical_declaration
|
||||
(variable_declarator
|
||||
name: (identifier) @debug-variable)))
|
||||
|
||||
(binary_expression
|
||||
left: (identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(binary_expression
|
||||
right: (identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(unary_expression
|
||||
argument: (identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(update_expression
|
||||
argument: (identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(return_statement
|
||||
(identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(parenthesized_expression
|
||||
(identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(array
|
||||
(identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(pair
|
||||
value: (identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(member_expression
|
||||
object: (identifier) @debug-variable
|
||||
(#not-match? @debug-variable "^[A-Z]"))
|
||||
|
||||
(statement_block) @debug-scope
|
||||
|
||||
(program) @debug-scope
|
||||
427
crates/grammars/src/javascript/highlights.scm
Normal file
427
crates/grammars/src/javascript/highlights.scm
Normal file
@@ -0,0 +1,427 @@
|
||||
; Variables
|
||||
(identifier) @variable
|
||||
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
object: (identifier) @type
|
||||
(#any-of? @type
|
||||
"Promise" "Array" "Object" "Map" "Set" "WeakMap" "WeakSet" "Date" "Error" "TypeError"
|
||||
"RangeError" "SyntaxError" "ReferenceError" "EvalError" "URIError" "RegExp" "Function"
|
||||
"Number" "String" "Boolean" "Symbol" "BigInt" "Proxy" "ArrayBuffer" "DataView")))
|
||||
|
||||
; Properties
|
||||
(property_identifier) @property
|
||||
|
||||
(shorthand_property_identifier) @property
|
||||
|
||||
(shorthand_property_identifier_pattern) @property
|
||||
|
||||
(private_property_identifier) @property
|
||||
|
||||
; Function and method calls
|
||||
(call_expression
|
||||
function: (identifier) @function)
|
||||
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
property: [
|
||||
(property_identifier)
|
||||
(private_property_identifier)
|
||||
] @function.method))
|
||||
|
||||
(new_expression
|
||||
constructor: (identifier) @type)
|
||||
|
||||
(nested_type_identifier
|
||||
module: (identifier) @type)
|
||||
|
||||
; Function and method definitions
|
||||
(function_expression
|
||||
name: (identifier) @function)
|
||||
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
(method_definition
|
||||
name: [
|
||||
(property_identifier)
|
||||
(private_property_identifier)
|
||||
] @function.method)
|
||||
|
||||
(method_definition
|
||||
name: (property_identifier) @constructor
|
||||
(#eq? @constructor "constructor"))
|
||||
|
||||
(pair
|
||||
key: [
|
||||
(property_identifier)
|
||||
(private_property_identifier)
|
||||
] @function.method
|
||||
value: [
|
||||
(function_expression)
|
||||
(arrow_function)
|
||||
])
|
||||
|
||||
(assignment_expression
|
||||
left: (member_expression
|
||||
property: [
|
||||
(property_identifier)
|
||||
(private_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)
|
||||
])
|
||||
|
||||
; Parameters
|
||||
(required_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(required_parameter
|
||||
(_
|
||||
([
|
||||
(identifier)
|
||||
(shorthand_property_identifier_pattern)
|
||||
]) @variable.parameter))
|
||||
|
||||
(optional_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
(optional_parameter
|
||||
(_
|
||||
([
|
||||
(identifier)
|
||||
(shorthand_property_identifier_pattern)
|
||||
]) @variable.parameter))
|
||||
|
||||
(catch_clause
|
||||
parameter: (identifier) @variable.parameter)
|
||||
|
||||
(index_signature
|
||||
name: (identifier) @variable.parameter)
|
||||
|
||||
(arrow_function
|
||||
parameter: (identifier) @variable.parameter)
|
||||
|
||||
; Special identifiers
|
||||
;
|
||||
(type_identifier) @type
|
||||
|
||||
(predefined_type) @type.builtin
|
||||
|
||||
(class_declaration
|
||||
(type_identifier) @type.class)
|
||||
|
||||
(extends_clause
|
||||
value: (identifier) @type.class)
|
||||
|
||||
([
|
||||
(identifier)
|
||||
(shorthand_property_identifier)
|
||||
(shorthand_property_identifier_pattern)
|
||||
] @constant
|
||||
(#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
|
||||
|
||||
; Literals
|
||||
(this) @variable.special
|
||||
|
||||
(super) @variable.special
|
||||
|
||||
[
|
||||
(null)
|
||||
(undefined)
|
||||
] @constant.builtin
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(comment) @comment
|
||||
|
||||
(hash_bang_line) @comment
|
||||
|
||||
[
|
||||
(string)
|
||||
(template_string)
|
||||
] @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(regex) @string.regex
|
||||
|
||||
(regex_flags) @keyword.operator.regex
|
||||
|
||||
(number) @number
|
||||
|
||||
; Tokens
|
||||
[
|
||||
";"
|
||||
"?."
|
||||
"."
|
||||
","
|
||||
":"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"-"
|
||||
"--"
|
||||
"-="
|
||||
"+"
|
||||
"++"
|
||||
"+="
|
||||
"*"
|
||||
"*="
|
||||
"**"
|
||||
"**="
|
||||
"/"
|
||||
"/="
|
||||
"%"
|
||||
"%="
|
||||
"<"
|
||||
"<="
|
||||
"<<"
|
||||
"<<="
|
||||
"="
|
||||
"=="
|
||||
"==="
|
||||
"!"
|
||||
"!="
|
||||
"!=="
|
||||
"=>"
|
||||
">"
|
||||
">="
|
||||
">>"
|
||||
">>="
|
||||
">>>"
|
||||
">>>="
|
||||
"~"
|
||||
"^"
|
||||
"&"
|
||||
"|"
|
||||
"^="
|
||||
"&="
|
||||
"|="
|
||||
"&&"
|
||||
"||"
|
||||
"??"
|
||||
"&&="
|
||||
"||="
|
||||
"??="
|
||||
"..."
|
||||
] @operator
|
||||
|
||||
(regex
|
||||
"/" @string.regex)
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
(ternary_expression
|
||||
[
|
||||
"?"
|
||||
":"
|
||||
] @operator)
|
||||
|
||||
[
|
||||
"abstract"
|
||||
"as"
|
||||
"async"
|
||||
"debugger"
|
||||
"declare"
|
||||
"default"
|
||||
"delete"
|
||||
"extends"
|
||||
"get"
|
||||
"implements"
|
||||
"in"
|
||||
"instanceof"
|
||||
"keyof"
|
||||
"module"
|
||||
"namespace"
|
||||
"new"
|
||||
"of"
|
||||
"override"
|
||||
"private"
|
||||
"protected"
|
||||
"public"
|
||||
"readonly"
|
||||
"set"
|
||||
"static"
|
||||
"target"
|
||||
"typeof"
|
||||
"using"
|
||||
"void"
|
||||
"with"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"const"
|
||||
"let"
|
||||
"var"
|
||||
"function"
|
||||
"class"
|
||||
"enum"
|
||||
"interface"
|
||||
"type"
|
||||
] @keyword.declaration
|
||||
|
||||
[
|
||||
"export"
|
||||
"from"
|
||||
"import"
|
||||
] @keyword.import
|
||||
|
||||
[
|
||||
"await"
|
||||
"break"
|
||||
"case"
|
||||
"catch"
|
||||
"continue"
|
||||
"do"
|
||||
"else"
|
||||
"finally"
|
||||
"for"
|
||||
"if"
|
||||
"return"
|
||||
"switch"
|
||||
"throw"
|
||||
"try"
|
||||
"while"
|
||||
"yield"
|
||||
] @keyword.control
|
||||
|
||||
(switch_default
|
||||
"default" @keyword.control)
|
||||
|
||||
(template_substitution
|
||||
"${" @punctuation.special
|
||||
"}" @punctuation.special) @embedded
|
||||
|
||||
(type_arguments
|
||||
"<" @punctuation.bracket
|
||||
">" @punctuation.bracket)
|
||||
|
||||
(decorator
|
||||
"@" @punctuation.special)
|
||||
|
||||
; JSX elements
|
||||
(jsx_opening_element
|
||||
[
|
||||
(identifier) @type @tag.component.jsx
|
||||
(member_expression
|
||||
object: (identifier) @type @tag.component.jsx
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
(member_expression
|
||||
object: (member_expression
|
||||
object: (identifier) @type @tag.component.jsx
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
(member_expression
|
||||
object: (member_expression
|
||||
object: (member_expression
|
||||
object: (identifier) @type @tag.component.jsx
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
])
|
||||
|
||||
(jsx_closing_element
|
||||
[
|
||||
(identifier) @type @tag.component.jsx
|
||||
(member_expression
|
||||
object: (identifier) @type @tag.component.jsx
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
(member_expression
|
||||
object: (member_expression
|
||||
object: (identifier) @type @tag.component.jsx
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
(member_expression
|
||||
object: (member_expression
|
||||
object: (member_expression
|
||||
object: (identifier) @type @tag.component.jsx
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
])
|
||||
|
||||
(jsx_self_closing_element
|
||||
[
|
||||
(identifier) @type @tag.component.jsx
|
||||
(member_expression
|
||||
object: (identifier) @type @tag.component.jsx
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
(member_expression
|
||||
object: (member_expression
|
||||
object: (identifier) @type @tag.component.jsx
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
(member_expression
|
||||
object: (member_expression
|
||||
object: (member_expression
|
||||
object: (identifier) @type @tag.component.jsx
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
property: (property_identifier) @type @tag.component.jsx)
|
||||
])
|
||||
|
||||
(jsx_opening_element
|
||||
(identifier) @tag.jsx
|
||||
(#match? @tag.jsx "^[a-z][^.]*$"))
|
||||
|
||||
(jsx_closing_element
|
||||
(identifier) @tag.jsx
|
||||
(#match? @tag.jsx "^[a-z][^.]*$"))
|
||||
|
||||
(jsx_self_closing_element
|
||||
(identifier) @tag.jsx
|
||||
(#match? @tag.jsx "^[a-z][^.]*$"))
|
||||
|
||||
(jsx_attribute
|
||||
(property_identifier) @attribute.jsx)
|
||||
|
||||
(jsx_opening_element
|
||||
([
|
||||
"<"
|
||||
">"
|
||||
]) @punctuation.bracket.jsx)
|
||||
|
||||
(jsx_closing_element
|
||||
([
|
||||
"</"
|
||||
">"
|
||||
]) @punctuation.bracket.jsx)
|
||||
|
||||
(jsx_self_closing_element
|
||||
([
|
||||
"<"
|
||||
"/>"
|
||||
]) @punctuation.bracket.jsx)
|
||||
|
||||
(jsx_attribute
|
||||
"=" @punctuation.delimiter.jsx)
|
||||
|
||||
(jsx_text) @text.jsx
|
||||
|
||||
(html_character_reference) @string.special
|
||||
33
crates/grammars/src/javascript/indents.scm
Normal file
33
crates/grammars/src/javascript/indents.scm
Normal file
@@ -0,0 +1,33 @@
|
||||
[
|
||||
(call_expression)
|
||||
(assignment_expression)
|
||||
(member_expression)
|
||||
(lexical_declaration)
|
||||
(variable_declaration)
|
||||
(assignment_expression)
|
||||
(if_statement)
|
||||
(for_statement)
|
||||
] @indent
|
||||
|
||||
(_
|
||||
"["
|
||||
"]" @end) @indent
|
||||
|
||||
(_
|
||||
"<"
|
||||
">" @end) @indent
|
||||
|
||||
(_
|
||||
"{"
|
||||
"}" @end) @indent
|
||||
|
||||
(_
|
||||
"("
|
||||
")" @end) @indent
|
||||
|
||||
(jsx_opening_element
|
||||
">" @end) @indent
|
||||
|
||||
(jsx_element
|
||||
(jsx_opening_element) @start
|
||||
(jsx_closing_element)? @end) @indent
|
||||
144
crates/grammars/src/javascript/injections.scm
Normal file
144
crates/grammars/src/javascript/injections.scm
Normal file
@@ -0,0 +1,144 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(((comment) @_jsdoc_comment
|
||||
(#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @injection.content
|
||||
(#set! injection.language "jsdoc"))
|
||||
|
||||
((regex) @injection.content
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "css")
|
||||
arguments: (template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "css")))
|
||||
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
object: (identifier) @_obj
|
||||
(#eq? @_obj "styled")
|
||||
property: (property_identifier))
|
||||
arguments: (template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "css")))
|
||||
|
||||
(call_expression
|
||||
function: (call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "styled"))
|
||||
arguments: (template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "css")))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "html")
|
||||
arguments: (template_string) @injection.content
|
||||
(#set! injection.language "html"))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "js")
|
||||
arguments: (template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "javascript")))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "json")
|
||||
arguments: (template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "json")))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "sql")
|
||||
arguments: (template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "sql")))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "ts")
|
||||
arguments: (template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "typescript")))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#match? @_name "^ya?ml$")
|
||||
arguments: (template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "yaml")))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#match? @_name "^g(raph)?ql$")
|
||||
arguments: (template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "graphql")))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#match? @_name "^g(raph)?ql$")
|
||||
arguments: (arguments
|
||||
(template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "graphql"))))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name
|
||||
(#match? @_name "^iso$")
|
||||
arguments: (arguments
|
||||
(template_string
|
||||
(string_fragment) @injection.content
|
||||
(#set! injection.language "isograph"))))
|
||||
|
||||
; Parse the contents of strings and tagged template
|
||||
; literals with leading ECMAScript comments:
|
||||
; '/* html */' or '/*html*/'
|
||||
(((comment) @_ecma_comment
|
||||
[
|
||||
(string
|
||||
(string_fragment) @injection.content)
|
||||
(template_string
|
||||
(string_fragment) @injection.content)
|
||||
])
|
||||
(#match? @_ecma_comment "^\\/\\*\\s*html\\s*\\*\\/")
|
||||
(#set! injection.language "html"))
|
||||
|
||||
; '/* sql */' or '/*sql*/'
|
||||
(((comment) @_ecma_comment
|
||||
[
|
||||
(string
|
||||
(string_fragment) @injection.content)
|
||||
(template_string
|
||||
(string_fragment) @injection.content)
|
||||
])
|
||||
(#match? @_ecma_comment "^\\/\\*\\s*sql\\s*\\*\\/")
|
||||
(#set! injection.language "sql"))
|
||||
|
||||
; '/* gql */' or '/*gql*/'
|
||||
; '/* graphql */' or '/*graphql*/'
|
||||
(((comment) @_ecma_comment
|
||||
[
|
||||
(string
|
||||
(string_fragment) @injection.content)
|
||||
(template_string
|
||||
(string_fragment) @injection.content)
|
||||
])
|
||||
(#match? @_ecma_comment "^\\/\\*\\s*(gql|graphql)\\s*\\*\\/")
|
||||
(#set! injection.language "graphql"))
|
||||
|
||||
; '/* css */' or '/*css*/'
|
||||
(((comment) @_ecma_comment
|
||||
[
|
||||
(string
|
||||
(string_fragment) @injection.content)
|
||||
(template_string
|
||||
(string_fragment) @injection.content)
|
||||
])
|
||||
(#match? @_ecma_comment "^\\/\\*\\s*(css)\\s*\\*\\/")
|
||||
(#set! injection.language "css"))
|
||||
268
crates/grammars/src/javascript/outline.scm
Normal file
268
crates/grammars/src/javascript/outline.scm
Normal file
@@ -0,0 +1,268 @@
|
||||
(internal_module
|
||||
"namespace" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(enum_declaration
|
||||
"enum" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(function_declaration
|
||||
"async"? @context
|
||||
"function" @context
|
||||
name: (_) @name
|
||||
parameters: (formal_parameters
|
||||
"(" @context
|
||||
")" @context)) @item
|
||||
|
||||
(generator_function_declaration
|
||||
"async"? @context
|
||||
"function" @context
|
||||
"*" @context
|
||||
name: (_) @name
|
||||
parameters: (formal_parameters
|
||||
"(" @context
|
||||
")" @context)) @item
|
||||
|
||||
(interface_declaration
|
||||
"interface" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(program
|
||||
(export_statement
|
||||
(lexical_declaration
|
||||
[
|
||||
"let"
|
||||
"const"
|
||||
] @context
|
||||
(variable_declarator
|
||||
name: (identifier) @name) @item)))
|
||||
|
||||
; Exported array destructuring
|
||||
(program
|
||||
(export_statement
|
||||
(lexical_declaration
|
||||
[
|
||||
"let"
|
||||
"const"
|
||||
] @context
|
||||
(variable_declarator
|
||||
name: (array_pattern
|
||||
[
|
||||
(identifier) @name @item
|
||||
(assignment_pattern
|
||||
left: (identifier) @name @item)
|
||||
(rest_pattern
|
||||
(identifier) @name @item)
|
||||
])))))
|
||||
|
||||
; Exported object destructuring
|
||||
(program
|
||||
(export_statement
|
||||
(lexical_declaration
|
||||
[
|
||||
"let"
|
||||
"const"
|
||||
] @context
|
||||
(variable_declarator
|
||||
name: (object_pattern
|
||||
[
|
||||
(shorthand_property_identifier_pattern) @name @item
|
||||
(pair_pattern
|
||||
value: (identifier) @name @item)
|
||||
(pair_pattern
|
||||
value: (assignment_pattern
|
||||
left: (identifier) @name @item))
|
||||
(rest_pattern
|
||||
(identifier) @name @item)
|
||||
])))))
|
||||
|
||||
(program
|
||||
(lexical_declaration
|
||||
[
|
||||
"let"
|
||||
"const"
|
||||
] @context
|
||||
(variable_declarator
|
||||
name: (identifier) @name) @item))
|
||||
|
||||
; Top-level array destructuring
|
||||
(program
|
||||
(lexical_declaration
|
||||
[
|
||||
"let"
|
||||
"const"
|
||||
] @context
|
||||
(variable_declarator
|
||||
name: (array_pattern
|
||||
[
|
||||
(identifier) @name @item
|
||||
(assignment_pattern
|
||||
left: (identifier) @name @item)
|
||||
(rest_pattern
|
||||
(identifier) @name @item)
|
||||
]))))
|
||||
|
||||
; Top-level object destructuring
|
||||
(program
|
||||
(lexical_declaration
|
||||
[
|
||||
"let"
|
||||
"const"
|
||||
] @context
|
||||
(variable_declarator
|
||||
name: (object_pattern
|
||||
[
|
||||
(shorthand_property_identifier_pattern) @name @item
|
||||
(pair_pattern
|
||||
value: (identifier) @name @item)
|
||||
(pair_pattern
|
||||
value: (assignment_pattern
|
||||
left: (identifier) @name @item))
|
||||
(rest_pattern
|
||||
(identifier) @name @item)
|
||||
]))))
|
||||
|
||||
(class_declaration
|
||||
"class" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
; Method definitions in classes (not in object literals)
|
||||
(class_body
|
||||
(method_definition
|
||||
[
|
||||
"get"
|
||||
"set"
|
||||
"async"
|
||||
"*"
|
||||
"readonly"
|
||||
"static"
|
||||
(override_modifier)
|
||||
(accessibility_modifier)
|
||||
]* @context
|
||||
name: (_) @name
|
||||
parameters: (formal_parameters
|
||||
"(" @context
|
||||
")" @context)) @item)
|
||||
|
||||
; Object literal methods (including nested objects)
|
||||
(object
|
||||
(method_definition
|
||||
[
|
||||
"get"
|
||||
"set"
|
||||
"async"
|
||||
"*"
|
||||
]* @context
|
||||
name: (_) @name
|
||||
parameters: (formal_parameters
|
||||
"(" @context
|
||||
")" @context)) @item)
|
||||
|
||||
(public_field_definition
|
||||
[
|
||||
"declare"
|
||||
"readonly"
|
||||
"abstract"
|
||||
"static"
|
||||
(accessibility_modifier)
|
||||
]* @context
|
||||
name: (_) @name) @item
|
||||
|
||||
; Add support for (node:test, bun:test and Jest) runnable
|
||||
((call_expression
|
||||
function: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: (identifier) @_name)
|
||||
])
|
||||
] @context
|
||||
(#any-of? @_name "it" "test" "describe" "context" "suite")
|
||||
arguments: (arguments
|
||||
.
|
||||
[
|
||||
(string
|
||||
(string_fragment) @name)
|
||||
(identifier) @name
|
||||
]))) @item
|
||||
|
||||
; Add support for parameterized tests
|
||||
((call_expression
|
||||
function: (call_expression
|
||||
function: (member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: (identifier) @_name)
|
||||
]
|
||||
property: (property_identifier) @_property)
|
||||
(#any-of? @_name "it" "test" "describe" "context" "suite")
|
||||
(#eq? @_property "each"))
|
||||
arguments: (arguments
|
||||
.
|
||||
[
|
||||
(string
|
||||
(string_fragment) @name)
|
||||
(identifier) @name
|
||||
]))) @item
|
||||
|
||||
; Object properties
|
||||
(pair
|
||||
key: [
|
||||
(property_identifier) @name
|
||||
(string
|
||||
(string_fragment) @name)
|
||||
(number) @name
|
||||
(computed_property_name) @name
|
||||
]) @item
|
||||
|
||||
; Nested variables in function bodies
|
||||
(statement_block
|
||||
(lexical_declaration
|
||||
[
|
||||
"let"
|
||||
"const"
|
||||
] @context
|
||||
(variable_declarator
|
||||
name: (identifier) @name) @item))
|
||||
|
||||
; Nested array destructuring in functions
|
||||
(statement_block
|
||||
(lexical_declaration
|
||||
[
|
||||
"let"
|
||||
"const"
|
||||
] @context
|
||||
(variable_declarator
|
||||
name: (array_pattern
|
||||
[
|
||||
(identifier) @name @item
|
||||
(assignment_pattern
|
||||
left: (identifier) @name @item)
|
||||
(rest_pattern
|
||||
(identifier) @name @item)
|
||||
]))))
|
||||
|
||||
; Nested object destructuring in functions
|
||||
(statement_block
|
||||
(lexical_declaration
|
||||
[
|
||||
"let"
|
||||
"const"
|
||||
] @context
|
||||
(variable_declarator
|
||||
name: (object_pattern
|
||||
[
|
||||
(shorthand_property_identifier_pattern) @name @item
|
||||
(pair_pattern
|
||||
value: (identifier) @name @item)
|
||||
(pair_pattern
|
||||
value: (assignment_pattern
|
||||
left: (identifier) @name @item))
|
||||
(rest_pattern
|
||||
(identifier) @name @item)
|
||||
]))))
|
||||
|
||||
(comment) @annotation
|
||||
15
crates/grammars/src/javascript/overrides.scm
Normal file
15
crates/grammars/src/javascript/overrides.scm
Normal file
@@ -0,0 +1,15 @@
|
||||
(comment) @comment.inclusive
|
||||
|
||||
(string) @string
|
||||
|
||||
(template_string
|
||||
(string_fragment) @string)
|
||||
|
||||
(jsx_element) @element
|
||||
|
||||
[
|
||||
(jsx_opening_element)
|
||||
(jsx_closing_element)
|
||||
(jsx_self_closing_element)
|
||||
(jsx_expression)
|
||||
] @default
|
||||
42
crates/grammars/src/javascript/runnables.scm
Normal file
42
crates/grammars/src/javascript/runnables.scm
Normal file
@@ -0,0 +1,42 @@
|
||||
; Add support for (node:test, bun:test and Jest) runnable
|
||||
; Function expression that has `it`, `test` or `describe` as the function name
|
||||
((call_expression
|
||||
function: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: (identifier) @_name)
|
||||
])
|
||||
]
|
||||
(#any-of? @_name "it" "test" "describe" "context" "suite")
|
||||
arguments: (arguments
|
||||
.
|
||||
[
|
||||
(string
|
||||
(string_fragment) @run)
|
||||
(identifier) @run
|
||||
])) @_js-test
|
||||
(#set! tag js-test))
|
||||
|
||||
; Add support for parameterized tests
|
||||
((call_expression
|
||||
function: (call_expression
|
||||
function: (member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: (identifier) @_name)
|
||||
]
|
||||
property: (property_identifier) @_property)
|
||||
(#any-of? @_name "it" "test" "describe" "context" "suite")
|
||||
(#eq? @_property "each"))
|
||||
arguments: (arguments
|
||||
.
|
||||
[
|
||||
(string
|
||||
(string_fragment) @run)
|
||||
(identifier) @run
|
||||
])) @_js-test
|
||||
(#set! tag js-test))
|
||||
91
crates/grammars/src/javascript/textobjects.scm
Normal file
91
crates/grammars/src/javascript/textobjects.scm
Normal file
@@ -0,0 +1,91 @@
|
||||
(comment)+ @comment.around
|
||||
|
||||
(function_declaration
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
(method_definition
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
(function_expression
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
((arrow_function
|
||||
body: (statement_block
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
(#not-has-parent? @function.around variable_declarator))
|
||||
|
||||
; Arrow function in variable declaration - capture the full declaration
|
||||
([
|
||||
(lexical_declaration
|
||||
(variable_declarator
|
||||
value: (arrow_function
|
||||
body: (statement_block
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}"))))
|
||||
(variable_declaration
|
||||
(variable_declarator
|
||||
value: (arrow_function
|
||||
body: (statement_block
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}"))))
|
||||
]) @function.around
|
||||
|
||||
; Arrow function in variable declaration (captures body for expression-bodied arrows)
|
||||
([
|
||||
(lexical_declaration
|
||||
(variable_declarator
|
||||
value: (arrow_function
|
||||
body: (_) @function.inside)))
|
||||
(variable_declaration
|
||||
(variable_declarator
|
||||
value: (arrow_function
|
||||
body: (_) @function.inside)))
|
||||
]) @function.around
|
||||
|
||||
; Catch-all for arrow functions in other contexts (callbacks, etc.)
|
||||
((arrow_function
|
||||
body: (_) @function.inside) @function.around
|
||||
(#not-has-parent? @function.around variable_declarator))
|
||||
|
||||
(generator_function
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
(generator_function_declaration
|
||||
body: (_
|
||||
"{"
|
||||
(_)* @function.inside
|
||||
"}")) @function.around
|
||||
|
||||
(class_declaration
|
||||
body: (_
|
||||
"{"
|
||||
[
|
||||
(_)
|
||||
";"?
|
||||
]* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(class
|
||||
body: (_
|
||||
"{"
|
||||
[
|
||||
(_)
|
||||
";"?
|
||||
]* @class.inside
|
||||
"}")) @class.around
|
||||
5
crates/grammars/src/jsdoc/brackets.scm
Normal file
5
crates/grammars/src/jsdoc/brackets.scm
Normal file
@@ -0,0 +1,5 @@
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
8
crates/grammars/src/jsdoc/config.toml
Normal file
8
crates/grammars/src/jsdoc/config.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
name = "JSDoc"
|
||||
grammar = "jsdoc"
|
||||
autoclose_before = "]}"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = false },
|
||||
{ start = "[", end = "]", close = true, newline = false },
|
||||
]
|
||||
hidden = true
|
||||
5
crates/grammars/src/jsdoc/highlights.scm
Normal file
5
crates/grammars/src/jsdoc/highlights.scm
Normal file
@@ -0,0 +1,5 @@
|
||||
(tag_name) @keyword.jsdoc
|
||||
|
||||
(type) @type.jsdoc
|
||||
|
||||
(identifier) @variable.jsdoc
|
||||
9
crates/grammars/src/json/brackets.scm
Normal file
9
crates/grammars/src/json/brackets.scm
Normal file
@@ -0,0 +1,9 @@
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
|
||||
(("\"" @open
|
||||
"\"" @close)
|
||||
(#set! rainbow.exclude))
|
||||
18
crates/grammars/src/json/config.toml
Normal file
18
crates/grammars/src/json/config.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
name = "JSON"
|
||||
grammar = "json"
|
||||
path_suffixes = ["json", "flake.lock", "geojson", "topojson", "prettierrc", "json.dist"]
|
||||
line_comments = ["// "]
|
||||
autoclose_before = ",]}"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, surround = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, surround = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, surround = true, newline = false },
|
||||
{ start = "\"", end = "\"", close = true, surround = true, newline = false, not_in = ["string"] },
|
||||
]
|
||||
tab_size = 2
|
||||
prettier_parser_name = "json"
|
||||
debuggers = ["JavaScript"]
|
||||
word_characters = ["#"]
|
||||
|
||||
[overrides.string]
|
||||
completion_query_characters = [":", " ", "."]
|
||||
29
crates/grammars/src/json/highlights.scm
Normal file
29
crates/grammars/src/json/highlights.scm
Normal file
@@ -0,0 +1,29 @@
|
||||
(comment) @comment
|
||||
|
||||
(string) @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(pair
|
||||
key: (string) @property.json_key)
|
||||
|
||||
(number) @number
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(null) @constant.builtin
|
||||
|
||||
[
|
||||
","
|
||||
":"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
5
crates/grammars/src/json/indents.scm
Normal file
5
crates/grammars/src/json/indents.scm
Normal file
@@ -0,0 +1,5 @@
|
||||
(array
|
||||
"]" @end) @indent
|
||||
|
||||
(object
|
||||
"}" @end) @indent
|
||||
3
crates/grammars/src/json/outline.scm
Normal file
3
crates/grammars/src/json/outline.scm
Normal file
@@ -0,0 +1,3 @@
|
||||
(pair
|
||||
key: (string
|
||||
(string_content) @name)) @item
|
||||
1
crates/grammars/src/json/overrides.scm
Normal file
1
crates/grammars/src/json/overrides.scm
Normal file
@@ -0,0 +1 @@
|
||||
(string) @string
|
||||
11
crates/grammars/src/json/redactions.scm
Normal file
11
crates/grammars/src/json/redactions.scm
Normal file
@@ -0,0 +1,11 @@
|
||||
(pair
|
||||
value: (number) @redact)
|
||||
|
||||
(pair
|
||||
value: (string) @redact)
|
||||
|
||||
(array
|
||||
(number) @redact)
|
||||
|
||||
(array
|
||||
(string) @redact)
|
||||
13
crates/grammars/src/json/runnables.scm
Normal file
13
crates/grammars/src/json/runnables.scm
Normal file
@@ -0,0 +1,13 @@
|
||||
; Add support `package.json` and `composer.json` script runnable
|
||||
((document
|
||||
(object
|
||||
(pair
|
||||
key: (string
|
||||
(string_content) @_name
|
||||
(#eq? @_name "scripts"))
|
||||
value: (object
|
||||
(pair
|
||||
key: (string
|
||||
(string_content) @run @script))))))
|
||||
(#set! tag package-script)
|
||||
(#set! tag composer-script))
|
||||
1
crates/grammars/src/json/textobjects.scm
Normal file
1
crates/grammars/src/json/textobjects.scm
Normal file
@@ -0,0 +1 @@
|
||||
(comment)+ @comment.around
|
||||
9
crates/grammars/src/jsonc/brackets.scm
Normal file
9
crates/grammars/src/jsonc/brackets.scm
Normal file
@@ -0,0 +1,9 @@
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
|
||||
(("\"" @open
|
||||
"\"" @close)
|
||||
(#set! rainbow.exclude))
|
||||
17
crates/grammars/src/jsonc/config.toml
Normal file
17
crates/grammars/src/jsonc/config.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
name = "JSONC"
|
||||
grammar = "jsonc"
|
||||
path_suffixes = ["jsonc", "bun.lock", "devcontainer.json", "pyrightconfig.json", "tsconfig.json", "luaurc", "swcrc", "babelrc", "eslintrc", "stylelintrc", "jshintrc"]
|
||||
line_comments = ["// "]
|
||||
block_comment = { start = "/*", prefix = "", end = "*/", tab_size = 1 }
|
||||
autoclose_before = ",]}"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, surround = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, surround = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, surround = true, newline = false },
|
||||
{ start = "\"", end = "\"", close = true, surround = true, newline = false, not_in = ["string"] },
|
||||
]
|
||||
tab_size = 2
|
||||
prettier_parser_name = "jsonc"
|
||||
|
||||
[overrides.string]
|
||||
completion_query_characters = [":", " "]
|
||||
29
crates/grammars/src/jsonc/highlights.scm
Normal file
29
crates/grammars/src/jsonc/highlights.scm
Normal file
@@ -0,0 +1,29 @@
|
||||
(comment) @comment
|
||||
|
||||
(string) @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(pair
|
||||
key: (string) @property.json_key)
|
||||
|
||||
(number) @number
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(null) @constant.builtin
|
||||
|
||||
[
|
||||
","
|
||||
":"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
5
crates/grammars/src/jsonc/indents.scm
Normal file
5
crates/grammars/src/jsonc/indents.scm
Normal file
@@ -0,0 +1,5 @@
|
||||
(array
|
||||
"]" @end) @indent
|
||||
|
||||
(object
|
||||
"}" @end) @indent
|
||||
2
crates/grammars/src/jsonc/injections.scm
Normal file
2
crates/grammars/src/jsonc/injections.scm
Normal file
@@ -0,0 +1,2 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
3
crates/grammars/src/jsonc/outline.scm
Normal file
3
crates/grammars/src/jsonc/outline.scm
Normal file
@@ -0,0 +1,3 @@
|
||||
(pair
|
||||
key: (string
|
||||
(string_content) @name)) @item
|
||||
3
crates/grammars/src/jsonc/overrides.scm
Normal file
3
crates/grammars/src/jsonc/overrides.scm
Normal file
@@ -0,0 +1,3 @@
|
||||
(comment) @comment.inclusive
|
||||
|
||||
(string) @string
|
||||
11
crates/grammars/src/jsonc/redactions.scm
Normal file
11
crates/grammars/src/jsonc/redactions.scm
Normal file
@@ -0,0 +1,11 @@
|
||||
(pair
|
||||
value: (number) @redact)
|
||||
|
||||
(pair
|
||||
value: (string) @redact)
|
||||
|
||||
(array
|
||||
(number) @redact)
|
||||
|
||||
(array
|
||||
(string) @redact)
|
||||
1
crates/grammars/src/jsonc/textobjects.scm
Normal file
1
crates/grammars/src/jsonc/textobjects.scm
Normal file
@@ -0,0 +1 @@
|
||||
(comment)+ @comment.around
|
||||
3
crates/grammars/src/markdown-inline/config.toml
Normal file
3
crates/grammars/src/markdown-inline/config.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
name = "Markdown-Inline"
|
||||
grammar = "markdown-inline"
|
||||
hidden = true
|
||||
35
crates/grammars/src/markdown-inline/highlights.scm
Normal file
35
crates/grammars/src/markdown-inline/highlights.scm
Normal file
@@ -0,0 +1,35 @@
|
||||
(emphasis) @emphasis.markup
|
||||
|
||||
(strong_emphasis) @emphasis.strong.markup
|
||||
|
||||
(code_span) @text.literal.markup
|
||||
|
||||
(strikethrough) @strikethrough.markup
|
||||
|
||||
[
|
||||
(inline_link)
|
||||
(shortcut_link)
|
||||
(collapsed_reference_link)
|
||||
(full_reference_link)
|
||||
(image)
|
||||
(link_text)
|
||||
(link_label)
|
||||
] @link_text.markup
|
||||
|
||||
(inline_link
|
||||
[
|
||||
"("
|
||||
")"
|
||||
] @link_uri.markup)
|
||||
|
||||
(image
|
||||
[
|
||||
"("
|
||||
")"
|
||||
] @link_uri.markup)
|
||||
|
||||
[
|
||||
(link_destination)
|
||||
(uri_autolink)
|
||||
(email_autolink)
|
||||
] @link_uri.markup
|
||||
2
crates/grammars/src/markdown-inline/injections.scm
Normal file
2
crates/grammars/src/markdown-inline/injections.scm
Normal file
@@ -0,0 +1,2 @@
|
||||
((latex_block) @injection.content
|
||||
(#set! injection.language "latex"))
|
||||
24
crates/grammars/src/markdown/brackets.scm
Normal file
24
crates/grammars/src/markdown/brackets.scm
Normal file
@@ -0,0 +1,24 @@
|
||||
("(" @open
|
||||
")" @close)
|
||||
|
||||
("[" @open
|
||||
"]" @close)
|
||||
|
||||
("{" @open
|
||||
"}" @close)
|
||||
|
||||
(("\"" @open
|
||||
"\"" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("`" @open
|
||||
"`" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(("'" @open
|
||||
"'" @close)
|
||||
(#set! rainbow.exclude))
|
||||
|
||||
(((fenced_code_block_delimiter) @open
|
||||
(fenced_code_block_delimiter) @close)
|
||||
(#set! rainbow.exclude))
|
||||
36
crates/grammars/src/markdown/config.toml
Normal file
36
crates/grammars/src/markdown/config.toml
Normal file
@@ -0,0 +1,36 @@
|
||||
name = "Markdown"
|
||||
grammar = "markdown"
|
||||
path_suffixes = ["md", "mdx", "mdwn", "mdc", "markdown", "MD"]
|
||||
modeline_aliases = ["md"]
|
||||
completion_query_characters = ["-"]
|
||||
block_comment = { start = "<!--", prefix = "", end = "-->", tab_size = 1 }
|
||||
autoclose_before = ";:.,=}])>"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "<", end = ">", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = false, newline = false },
|
||||
{ start = "'", end = "'", close = false, newline = false },
|
||||
{ start = "`", end = "`", close = false, newline = false },
|
||||
{ start = "*", end = "*", close = false, newline = false, surround = true },
|
||||
]
|
||||
rewrap_prefixes = [
|
||||
"[-*+]\\s+",
|
||||
"\\d+\\.\\s+",
|
||||
">\\s*",
|
||||
"[-*+]\\s+\\[[\\sx]\\]\\s+"
|
||||
]
|
||||
unordered_list = ["- ", "* ", "+ "]
|
||||
ordered_list = [{ pattern = "(\\d+)\\. ", format = "{1}. " }]
|
||||
task_list = { prefixes = ["- [ ] ", "- [x] ", "- [X] "], continuation = "- [ ] " }
|
||||
|
||||
auto_indent_on_paste = false
|
||||
auto_indent_using_last_non_empty_line = false
|
||||
tab_size = 2
|
||||
decrease_indent_patterns = [
|
||||
{ pattern = "^\\s*-", valid_after = ["list_item"] },
|
||||
{ pattern = "^\\s*\\d", valid_after = ["list_item"] },
|
||||
{ pattern = "^\\s*", valid_after = ["list_item"] },
|
||||
]
|
||||
prettier_parser_name = "markdown"
|
||||
48
crates/grammars/src/markdown/highlights.scm
Normal file
48
crates/grammars/src/markdown/highlights.scm
Normal file
@@ -0,0 +1,48 @@
|
||||
[
|
||||
(paragraph)
|
||||
(indented_code_block)
|
||||
(pipe_table)
|
||||
] @text
|
||||
|
||||
[
|
||||
(atx_heading)
|
||||
(setext_heading)
|
||||
(thematic_break)
|
||||
] @title.markup
|
||||
|
||||
(setext_heading
|
||||
(paragraph) @title.markup)
|
||||
|
||||
[
|
||||
(list_marker_plus)
|
||||
(list_marker_minus)
|
||||
(list_marker_star)
|
||||
(list_marker_dot)
|
||||
(list_marker_parenthesis)
|
||||
] @punctuation.list_marker.markup
|
||||
|
||||
[
|
||||
(block_quote_marker)
|
||||
(block_continuation)
|
||||
] @punctuation.markup
|
||||
|
||||
(pipe_table_header
|
||||
"|" @punctuation.markup)
|
||||
|
||||
(pipe_table_row
|
||||
"|" @punctuation.markup)
|
||||
|
||||
(pipe_table_delimiter_row
|
||||
"|" @punctuation.markup)
|
||||
|
||||
(pipe_table_delimiter_cell
|
||||
"-" @punctuation.markup)
|
||||
|
||||
[
|
||||
(fenced_code_block_delimiter)
|
||||
(info_string)
|
||||
] @punctuation.embedded.markup
|
||||
|
||||
(link_reference_definition) @link_text.markup
|
||||
|
||||
(link_destination) @link_uri.markup
|
||||
4
crates/grammars/src/markdown/indents.scm
Normal file
4
crates/grammars/src/markdown/indents.scm
Normal file
@@ -0,0 +1,4 @@
|
||||
(list
|
||||
(list_item) @indent)
|
||||
|
||||
(list_item) @start.list_item
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user