on master help sign in
Replace Mode::Goto with just using on_next_key.
aefafc2Blaž Hrastnik
helix-term/src/commands.rs+23−6
@@ -1032,7 +1032,24 @@ pub fn normal_mode(cx: &mut Context) {
1032}
1032}
1033
1033
1034pub fn goto_mode(cx: &mut Context) {
1034pub fn goto_mode(cx: &mut Context) {
1035− cx.doc().mode = Mode::Goto;
1035+ cx.on_next_key(move |cx, event| {
1036+ if let KeyEvent {
1037+ code: KeyCode::Char(ch),
1038+ ..
1039+ } = event
1040+ {
1041+ // TODO: temporarily show GOTO in the mode list
1042+ match ch {
1043+ 'g' => move_file_start(cx),
1044+ 'e' => move_file_end(cx),
1045+ 'd' => goto_definition(cx),
1046+ 't' => goto_type_definition(cx),
1047+ 'r' => goto_reference(cx),
1048+ 'i' => goto_implementation(cx),
1049+ _ => (),
1050+ }
1051+ }
1052+ })
1036}
1053}
1037
1054
1038pub fn select_mode(cx: &mut Context) {
1055pub fn select_mode(cx: &mut Context) {
@@ -1043,7 +1060,7 @@ pub fn exit_select_mode(cx: &mut Context) {
1043 cx.doc().mode = Mode::Normal;
1060 cx.doc().mode = Mode::Normal;
1044}
1061}
1045
1062
1046−fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
1063+fn _goto(cx: &mut Context, locations: Vec<lsp::Location>) {
1047 use helix_view::editor::Action;
1064 use helix_view::editor::Action;
1048 cx.doc().mode = Mode::Normal;
1065 cx.doc().mode = Mode::Normal;
1049
1066
@@ -1093,7 +1110,7 @@ pub fn goto_definition(cx: &mut Context) {
1093 // TODO: handle fails
1110 // TODO: handle fails
1094 let res =
1111 let res =
1095 smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default();
1112 smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default();
1096− goto(cx, res);
1113+ _goto(cx, res);
1097}
1114}
1098
1115
1099pub fn goto_type_definition(cx: &mut Context) {
1116pub fn goto_type_definition(cx: &mut Context) {
@@ -1109,7 +1126,7 @@ pub fn goto_type_definition(cx: &mut Context) {
1109 // TODO: handle fails
1126 // TODO: handle fails
1110 let res = smol::block_on(language_server.goto_type_definition(doc.identifier(), pos))
1127 let res = smol::block_on(language_server.goto_type_definition(doc.identifier(), pos))
1111 .unwrap_or_default();
1128 .unwrap_or_default();
1112− goto(cx, res);
1129+ _goto(cx, res);
1113}
1130}
1114
1131
1115pub fn goto_implementation(cx: &mut Context) {
1132pub fn goto_implementation(cx: &mut Context) {
@@ -1125,7 +1142,7 @@ pub fn goto_implementation(cx: &mut Context) {
1125 // TODO: handle fails
1142 // TODO: handle fails
1126 let res = smol::block_on(language_server.goto_implementation(doc.identifier(), pos))
1143 let res = smol::block_on(language_server.goto_implementation(doc.identifier(), pos))
1127 .unwrap_or_default();
1144 .unwrap_or_default();
1128− goto(cx, res);
1145+ _goto(cx, res);
1129}
1146}
1130
1147
1131pub fn goto_reference(cx: &mut Context) {
1148pub fn goto_reference(cx: &mut Context) {
@@ -1141,7 +1158,7 @@ pub fn goto_reference(cx: &mut Context) {
1141 // TODO: handle fails
1158 // TODO: handle fails
1142 let res =
1159 let res =
1143 smol::block_on(language_server.goto_reference(doc.identifier(), pos)).unwrap_or_default();
1160 smol::block_on(language_server.goto_reference(doc.identifier(), pos)).unwrap_or_default();
1144− goto(cx, res);
1161+ _goto(cx, res);
1145}
1162}
1146
1163
1147pub fn signature_help(cx: &mut Context) {
1164pub fn signature_help(cx: &mut Context) {
helix-term/src/keymap.rs−12
@@ -316,17 +316,5 @@ pub fn default() -> Keymaps {
316
316
317 ctrl!('x') => commands::completion,
317 ctrl!('x') => commands::completion,
318 ),
318 ),
319− Mode::Goto => hashmap!(
320− Key {
321− code: KeyCode::Esc,
322− modifiers: Modifiers::NONE
323− } => commands::normal_mode as Command,
324− key!('g') => commands::move_file_start,
325− key!('e') => commands::move_file_end,
326− key!('d') => commands::goto_definition,
327− key!('t') => commands::goto_type_definition,
328− key!('r') => commands::goto_reference,
329− key!('i') => commands::goto_implementation,
330− ),
331 )
319 )
332}
320}
helix-term/src/ui/editor.rs+1−1
@@ -37,6 +37,7 @@ impl EditorView {
37 on_next_key: None,
37 on_next_key: None,
38 }
38 }
39 }
39 }
40+
40 pub fn render_view(
41 pub fn render_view(
41 &self,
42 &self,
42 doc: &Document,
43 doc: &Document,
@@ -385,7 +386,6 @@ impl EditorView {
385 Mode::Insert => "INS",
386 Mode::Insert => "INS",
386 Mode::Select => "SEL",
387 Mode::Select => "SEL",
387 Mode::Normal => "NOR",
388 Mode::Normal => "NOR",
388− Mode::Goto => "GOTO",
389 };
389 };
390 // TODO: share text_color styles inside theme
390 // TODO: share text_color styles inside theme
391 let text_color = if is_focused {
391 let text_color = if is_focused {
helix-view/src/document.rs−1
@@ -15,7 +15,6 @@ pub enum Mode {
15 Normal,
15 Normal,
16 Select,
16 Select,
17 Insert,
17 Insert,
18− Goto,
19}
18}
20
19
21pub struct Document {
20pub struct Document {