on master help sign in
display tree sitter scopes in a popup (#4337)
commit1f74cf45d45804da8f33e173b26b3ddda82c706b authorRoberto Vidal <vidal.roberto.j@gmail.com> dateTue 18 Oct 2022, 20:30 (4 years ago) parentd17ffc4
1 file changed+15−1
helix-term/src/commands/typed.rs+15−1
helix-term/src/commands/typed.rs+15−1
@@ -1060,7 +1060,21 @@ fn tree_sitter_scopes(
10601060
10611061 let pos = doc.selection(view.id).primary().cursor(text);
10621062 let scopes = indent::get_scopes(doc.syntax(), text, pos);
1063− cx.editor.set_status(format!("scopes: {:?}", &scopes));
1063+
1064+ let contents = format!("```json\n{:?}\n````", scopes);
1065+
1066+ let callback = async move {
1067+ let call: job::Callback =
1068+ Box::new(move |editor: &mut Editor, compositor: &mut Compositor| {
1069+ let contents = ui::Markdown::new(contents, editor.syn_loader.clone());
1070+ let popup = Popup::new("hover", contents).auto_close(true);
1071+ compositor.replace_or_push("hover", popup);
1072+ });
1073+ Ok(call)
1074+ };
1075+
1076+ cx.jobs.callback(callback);
1077+
10641078 Ok(())
10651079}
10661080