Skip to main content

expand_leader

Function expand_leader 

Source
pub fn expand_leader(chord_str: &str, leader: &str) -> String
Expand description

Expand every <leader> / <Leader> token in chord_str to leader.

Textual, before parsing, and everywhere in the sequence rather than only at the front — vim expands <Leader> wherever it appears, and a chord like g<leader>x is legal there.

A leader value that does not itself parse is not this function’s problem: the expanded string goes through parse_chord_sequence like any other, so a malformed keymap.leader surfaces as an ordinary InvalidChord on each binding that used it — skipped and logged, never a panic.

Only the exact spellings <leader> and <Leader> are recognised (not <LEADER>). Most callers want KeymapHandle::expand_leader, which supplies the registry’s configured leader.

§Examples

use lattice_keymap::{DEFAULT_LEADER, expand_leader};

assert_eq!(expand_leader("<leader>ff", DEFAULT_LEADER), "<Space>ff");
assert_eq!(expand_leader("g<Leader>x", ","), "g,x");
assert_eq!(expand_leader("gd", ","), "gd");