diff options
author | Blaž Hrastnik | 2021-03-29 06:04:29 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-29 06:04:29 +0000 |
commit | aefafc25cd235183261efa2d59265855e0e992e1 (patch) | |
tree | e2ba4b01a27917a870031ef32e5109d576268987 /helix-term/src | |
parent | 1d96cbfbd2ef1d937490b1aaa19152dfc0ea0f76 (diff) |
Replace Mode::Goto with just using on_next_key.
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 29 | ||||
-rw-r--r-- | helix-term/src/keymap.rs | 12 | ||||
-rw-r--r-- | helix-term/src/ui/editor.rs | 2 |
3 files changed, 24 insertions, 19 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index bc1019d5..e1a03ee1 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1032,7 +1032,24 @@ pub fn normal_mode(cx: &mut Context) { } pub fn goto_mode(cx: &mut Context) { - cx.doc().mode = Mode::Goto; + cx.on_next_key(move |cx, event| { + if let KeyEvent { + code: KeyCode::Char(ch), + .. + } = event + { + // TODO: temporarily show GOTO in the mode list + match ch { + 'g' => move_file_start(cx), + 'e' => move_file_end(cx), + 'd' => goto_definition(cx), + 't' => goto_type_definition(cx), + 'r' => goto_reference(cx), + 'i' => goto_implementation(cx), + _ => (), + } + } + }) } pub fn select_mode(cx: &mut Context) { @@ -1043,7 +1060,7 @@ pub fn exit_select_mode(cx: &mut Context) { cx.doc().mode = Mode::Normal; } -fn goto(cx: &mut Context, locations: Vec<lsp::Location>) { +fn _goto(cx: &mut Context, locations: Vec<lsp::Location>) { use helix_view::editor::Action; cx.doc().mode = Mode::Normal; @@ -1093,7 +1110,7 @@ pub fn goto_definition(cx: &mut Context) { // TODO: handle fails let res = smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default(); - goto(cx, res); + _goto(cx, res); } pub fn goto_type_definition(cx: &mut Context) { @@ -1109,7 +1126,7 @@ pub fn goto_type_definition(cx: &mut Context) { // TODO: handle fails let res = smol::block_on(language_server.goto_type_definition(doc.identifier(), pos)) .unwrap_or_default(); - goto(cx, res); + _goto(cx, res); } pub fn goto_implementation(cx: &mut Context) { @@ -1125,7 +1142,7 @@ pub fn goto_implementation(cx: &mut Context) { // TODO: handle fails let res = smol::block_on(language_server.goto_implementation(doc.identifier(), pos)) .unwrap_or_default(); - goto(cx, res); + _goto(cx, res); } pub fn goto_reference(cx: &mut Context) { @@ -1141,7 +1158,7 @@ pub fn goto_reference(cx: &mut Context) { // TODO: handle fails let res = smol::block_on(language_server.goto_reference(doc.identifier(), pos)).unwrap_or_default(); - goto(cx, res); + _goto(cx, res); } pub fn signature_help(cx: &mut Context) { diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index aa1f8cce..f401f0f9 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -316,17 +316,5 @@ pub fn default() -> Keymaps { ctrl!('x') => commands::completion, ), - Mode::Goto => hashmap!( - Key { - code: KeyCode::Esc, - modifiers: Modifiers::NONE - } => commands::normal_mode as Command, - key!('g') => commands::move_file_start, - key!('e') => commands::move_file_end, - key!('d') => commands::goto_definition, - key!('t') => commands::goto_type_definition, - key!('r') => commands::goto_reference, - key!('i') => commands::goto_implementation, - ), ) } diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index f55411b8..bd0398a2 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -37,6 +37,7 @@ impl EditorView { on_next_key: None, } } + pub fn render_view( &self, doc: &Document, @@ -385,7 +386,6 @@ impl EditorView { Mode::Insert => "INS", Mode::Select => "SEL", Mode::Normal => "NOR", - Mode::Goto => "GOTO", }; // TODO: share text_color styles inside theme let text_color = if is_focused { |