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:
parent
313f5968eb
commit
58807f0dd2
6 changed files with 65 additions and 13 deletions
|
@ -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 {
|
||||
|
|
1
crates/languages/src/zed-keybind-context/brackets.scm
Normal file
1
crates/languages/src/zed-keybind-context/brackets.scm
Normal file
|
@ -0,0 +1 @@
|
|||
("(" @open ")" @close)
|
6
crates/languages/src/zed-keybind-context/config.toml
Normal file
6
crates/languages/src/zed-keybind-context/config.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
name = "Zed Keybind Context"
|
||||
grammar = "rust"
|
||||
autoclose_before = ")"
|
||||
brackets = [
|
||||
{ start = "(", end = ")", close = true, newline = false },
|
||||
]
|
23
crates/languages/src/zed-keybind-context/highlights.scm
Normal file
23
crates/languages/src/zed-keybind-context/highlights.scm
Normal file
|
@ -0,0 +1,23 @@
|
|||
(identifier) @variable
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
(integer_literal)
|
||||
(float_literal)
|
||||
] @number
|
||||
|
||||
(boolean_literal) @boolean
|
||||
|
||||
[
|
||||
"!="
|
||||
"=="
|
||||
"=>"
|
||||
">"
|
||||
"&&"
|
||||
"||"
|
||||
"!"
|
||||
] @operator
|
Loading…
Add table
Add a link
Reference in a new issue