logiguard fork: GPUI xdg-activation keyboard-focus serial fix
Some checks failed
Update All Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Triage Project Sync (#84) / Sync triage project (push) Has been cancelled
release_nightly / notify_on_failure (push) Has been cancelled
release_nightly / check_style (push) Has been cancelled
release_nightly / run_tests_windows (push) Has been cancelled
release_nightly / clippy_windows (push) Has been cancelled
release_nightly / bundle_linux_aarch64 (push) Has been cancelled
release_nightly / bundle_linux_x86_64 (push) Has been cancelled
release_nightly / bundle_mac_aarch64 (push) Has been cancelled
release_nightly / bundle_mac_x86_64 (push) Has been cancelled
release_nightly / bundle_windows_aarch64 (push) Has been cancelled
release_nightly / bundle_windows_x86_64 (push) Has been cancelled
release_nightly / build_nix_linux_x86_64 (push) Has been cancelled
release_nightly / build_nix_mac_aarch64 (push) Has been cancelled
release_nightly / update_nightly_tag (push) Has been cancelled
Hotfix Review Monitor / check-hotfix-reviews (push) Has been cancelled
Stale PR Review Reminder / check-stale-prs (push) Has been cancelled
Update Weekly Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Bump collab-staging Tag / update-collab-staging-tag (push) Has been cancelled
compliance_check / scheduled_compliance_check (push) Has been cancelled
Some checks failed
Update All Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Triage Project Sync (#84) / Sync triage project (push) Has been cancelled
release_nightly / notify_on_failure (push) Has been cancelled
release_nightly / check_style (push) Has been cancelled
release_nightly / run_tests_windows (push) Has been cancelled
release_nightly / clippy_windows (push) Has been cancelled
release_nightly / bundle_linux_aarch64 (push) Has been cancelled
release_nightly / bundle_linux_x86_64 (push) Has been cancelled
release_nightly / bundle_mac_aarch64 (push) Has been cancelled
release_nightly / bundle_mac_x86_64 (push) Has been cancelled
release_nightly / bundle_windows_aarch64 (push) Has been cancelled
release_nightly / bundle_windows_x86_64 (push) Has been cancelled
release_nightly / build_nix_linux_x86_64 (push) Has been cancelled
release_nightly / build_nix_mac_aarch64 (push) Has been cancelled
release_nightly / update_nightly_tag (push) Has been cancelled
Hotfix Review Monitor / check-hotfix-reviews (push) Has been cancelled
Stale PR Review Reminder / check-stale-prs (push) Has been cancelled
Update Weekly Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Bump collab-staging Tag / update-collab-staging-tag (push) Has been cancelled
compliance_check / scheduled_compliance_check (push) Has been cancelled
Single-commit orphan branch: full zed-industries/zed @ 8c74db0 source tree with a 3-file patch applied (no upstream history). Patch (crates/gpui_linux/src/linux/wayland/): - serial.rs: add SerialKind::KeyboardEnter - client.rs: store wl_keyboard.enter serial; add latest_serial_of() - window.rs: activate() uses keyboard-enter serial (Mutter focus gate) Mutter honors window activation only when the token carries the keyboard- focus serial from wl_keyboard.enter; GPUI used a stale mouse-press serial. See docs/tray-window-focus-wayland.md in logiguard. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user