A simple CPU rendered GUI IDE experience.
matching brace
bendn 8 weeks ago
parent 51a5832 · commit 587b0df
-rw-r--r--src/lsp.rs9
-rw-r--r--src/main.rs6
2 files changed, 15 insertions, 0 deletions
diff --git a/src/lsp.rs b/src/lsp.rs
index 3ba8e6e..92d5266 100644
--- a/src/lsp.rs
+++ b/src/lsp.rs
@@ -388,6 +388,14 @@ impl Client {
})
})
}
+ pub fn matching_brace<'a>(&'static self, f: &Path, t: &'a mut TextArea) {
+ if let Ok(Some([x])) = self.runtime.block_on(self.request::<lsp_request!("experimental/matchingBrace")>(&MatchingBraceParams {
+ text_document: f.tid(),
+ positions: vec![t.to_l_position(t.cursor).unwrap()],
+ }).unwrap().0) {
+ t.cursor = t.l_position(x).unwrap();
+ }
+ }
pub fn inlay(
&'static self,
f: &Path,
@@ -687,6 +695,7 @@ pub fn run(
..default()
}),
experimental: Some(json! {{
+ "matchingBrace": true,
"snippetTextEdit": true,
"colorDiagnosticOutput": true,
"codeActionGroup": true,
diff --git a/src/main.rs b/src/main.rs
index 93d43f6..7b5d1d2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1256,6 +1256,11 @@ hovering.request = (DropH::new(handle), cursor_position).into();
_ => {}
}
match o {
+ Some(Do::MatchingBrace) => {
+ if let Some((l, f)) = lsp!() {
+ l.matching_brace(f, &mut text);
+ }
+ }
Some(Do::Symbols) => {
if let Some(lsp) = lsp {
state = State::Symbols(Rq::new(lsp.runtime.spawn(window.redraw_after(lsp.symbols("".into())))));
@@ -1739,6 +1744,7 @@ Default => {
K(Key::Character(x) if x == "c" && ctrl()) => _,
K(Key::Character(x) if x == "l" && ctrl()) => _ [Symbols],
K(Key::Character(x) if x == "." && ctrl()) => _ [CodeAction],
+ K(Key::Character(x) if x == "0" && ctrl()) => _ [MatchingBrace],
K(Key::Named(ArrowUp | ArrowLeft | ArrowDown | ArrowRight | Home | End) if shift()) => Selection(Range<usize> => 0..0) [StartSelection],
M(MouseButton::Left if shift()) => Selection(Range<usize> => 0..0) [StartSelection],
M(MouseButton::Left if ctrl()) => _ [GoToDefinition],