keymap_ui: Create language for Zed keybind context (#34558)

Closes #ISSUE

Creates a new language in the languages crate for the DSL used in Zed
keybinding context. Previously, keybind context was highlighted as Rust
in the keymap UI due to the expression syntax of Rust matching that of
the context DSL, however, this had the side effect of highlighting upper
case contexts (e.g. `Editor`) however Rust types would be highlighted
based on the theme. By extracting only the necessary pieces of the Rust
language `highlights.scm`, `brackets.scm`, and `config.toml`, and
continuing to use the Rust grammar, we get a better result across
different themes

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Ben Kunkle 2025-07-16 12:00:47 -05:00 committed by GitHub
parent 313f5968eb
commit 58807f0dd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 65 additions and 13 deletions

View file

@ -212,6 +212,10 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
name: "gitcommit",
..Default::default()
},
LanguageInfo {
name: "zed-keybind-context",
..Default::default()
},
];
for registration in built_in_languages {

View file

@ -0,0 +1 @@
("(" @open ")" @close)

View file

@ -0,0 +1,6 @@
name = "Zed Keybind Context"
grammar = "rust"
autoclose_before = ")"
brackets = [
{ start = "(", end = ")", close = true, newline = false },
]

View file

@ -0,0 +1,23 @@
(identifier) @variable
[
"("
")"
] @punctuation.bracket
[
(integer_literal)
(float_literal)
] @number
(boolean_literal) @boolean
[
"!="
"=="
"=>"
">"
"&&"
"||"
"!"
] @operator