Skip to content

Commit

Permalink
Let jump keys be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
semin-park committed Jul 5, 2023
1 parent 183a5f1 commit 35ff1cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
6 changes: 3 additions & 3 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ use insert::*;
use movement::Movement;

use self::jump::{
cleanup, find_all_identifiers_in_view, find_all_str_occurrences_in_view,
show_key_annotations_with_callback, sort_jump_targets, JumpSequencer, TrieNode, JUMP_KEYS,
cleanup, find_all_identifiers_in_view, find_all_str_occurrences_in_view, jump_keys,
show_key_annotations_with_callback, sort_jump_targets, JumpSequencer, TrieNode,
};
use crate::{
args,
Expand Down Expand Up @@ -5669,7 +5669,7 @@ fn jump_with_targets(cx: &mut Context, mut jump_targets: Vec<Range>, extend_sele
jump_to(cx, jump_targets[0], extend_selection);
return cleanup(cx);
}
let root = TrieNode::build(JUMP_KEYS, jump_targets);
let root = TrieNode::build(&jump_keys(cx), jump_targets);
show_key_annotations_with_callback(cx, root.generate(), move |cx, event| {
handle_key_event(root, cx, event, extend_selection)
});
Expand Down
2 changes: 1 addition & 1 deletion helix-term/src/commands/jump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub(crate) mod locations;
pub(crate) mod score;
pub(crate) mod sequencer;

pub use annotate::{cleanup, setup, show_key_annotations_with_callback, JUMP_KEYS};
pub use annotate::{cleanup, jump_keys, setup, show_key_annotations_with_callback};
pub use locations::{find_all_identifiers_in_view, find_all_str_occurrences_in_view};
pub use score::sort_jump_targets;
pub use sequencer::{JumpAnnotation, JumpSequence, JumpSequencer, TrieNode};
10 changes: 9 additions & 1 deletion helix-term/src/commands/jump/annotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ use helix_core::text_annotations::Overlay;
use helix_view::{input::KeyEvent, View};
use std::rc::Rc;

pub const JUMP_KEYS: &[u8] = b"etovxqpdygfblzhckisuran";
pub fn jump_keys(ctx: &mut Context) -> Vec<u8> {
doc!(ctx.editor)
.config
.load()
.jump_mode
.jump_keys
.clone()
.into_bytes()
}

#[inline]
pub fn setup(ctx: &mut Context) {
Expand Down
3 changes: 3 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,16 @@ pub struct JumpModeConfig {
pub dim_during_jump: bool,
/// How many characters the user should type before labelling the targets.
pub num_chars_before_label: u8,
/// Keys used in labels. Should be convertible to u8
pub jump_keys: String,
}

impl Default for JumpModeConfig {
fn default() -> Self {
JumpModeConfig {
dim_during_jump: true,
num_chars_before_label: 1,
jump_keys: String::from("jwetovxqpdygfblzhckisuranm"),
}
}
}
Expand Down

0 comments on commit 35ff1cc

Please sign in to comment.