on master help sign in
Replace Mode::Goto with just using on_next_key.
commitaefafc25cd235183261efa2d59265855e0e992e1 authorBlaž Hrastnik <blaz@mxxn.io> dateMon 29 Mar 2021, 15:04 (6 years ago) parent1d96cbf
4 files changed+24−20
helix-term/src/commands.rs+23−6 helix-term/src/keymap.rs−12 helix-term/src/ui/editor.rs+1−1 helix-view/src/document.rs−1
helix-term/src/commands.rs+23−6
@@ -1032,7 +1032,24 @@ pub fn normal_mode(cx: &mut Context) {
10321032}
10331033
10341034pub 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+ })
10361053}
10371054
10381055pub fn select_mode(cx: &mut Context) {
@@ -1043,7 +1060,7 @@ pub fn exit_select_mode(cx: &mut Context) {
10431060 cx.doc().mode = Mode::Normal;
10441061}
10451062
1046−fn goto(cx: &mut Context, locations: Vec<lsp::Location>) {
1063+fn _goto(cx: &mut Context, locations: Vec<lsp::Location>) {
10471064 use helix_view::editor::Action;
10481065 cx.doc().mode = Mode::Normal;
10491066
@@ -1093,7 +1110,7 @@ pub fn goto_definition(cx: &mut Context) {
10931110 // TODO: handle fails
10941111 let res =
10951112 smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default();
1096− goto(cx, res);
1113+ _goto(cx, res);
10971114}
10981115
10991116pub fn goto_type_definition(cx: &mut Context) {
@@ -1109,7 +1126,7 @@ pub fn goto_type_definition(cx: &mut Context) {
11091126 // TODO: handle fails
11101127 let res = smol::block_on(language_server.goto_type_definition(doc.identifier(), pos))
11111128 .unwrap_or_default();
1112− goto(cx, res);
1129+ _goto(cx, res);
11131130}
11141131
11151132pub fn goto_implementation(cx: &mut Context) {
@@ -1125,7 +1142,7 @@ pub fn goto_implementation(cx: &mut Context) {
11251142 // TODO: handle fails
11261143 let res = smol::block_on(language_server.goto_implementation(doc.identifier(), pos))
11271144 .unwrap_or_default();
1128− goto(cx, res);
1145+ _goto(cx, res);
11291146}
11301147
11311148pub fn goto_reference(cx: &mut Context) {
@@ -1141,7 +1158,7 @@ pub fn goto_reference(cx: &mut Context) {
11411158 // TODO: handle fails
11421159 let res =
11431160 smol::block_on(language_server.goto_reference(doc.identifier(), pos)).unwrap_or_default();
1144− goto(cx, res);
1161+ _goto(cx, res);
11451162}
11461163
11471164pub fn signature_help(cx: &mut Context) {
helix-term/src/keymap.rs−12
@@ -316,17 +316,5 @@ pub fn default() -> Keymaps {
316316
317317 ctrl!('x') => commands::completion,
318318 ),
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− ),
331319 )
332320}
helix-term/src/ui/editor.rs+1−1
@@ -37,6 +37,7 @@ impl EditorView {
3737 on_next_key: None,
3838 }
3939 }
40+
4041 pub fn render_view(
4142 &self,
4243 doc: &Document,
@@ -385,7 +386,6 @@ impl EditorView {
385386 Mode::Insert => "INS",
386387 Mode::Select => "SEL",
387388 Mode::Normal => "NOR",
388− Mode::Goto => "GOTO",
389389 };
390390 // TODO: share text_color styles inside theme
391391 let text_color = if is_focused {
helix-view/src/document.rs−1
@@ -15,7 +15,6 @@ pub enum Mode {
1515 Normal,
1616 Select,
1717 Insert,
18− Goto,
1918}
2019
2120pub struct Document {