Skip to content

Allow any keys to drive navigation - #11

Open
spenthil wants to merge 1 commit into
paulbkim-dev:mainfrom
spenthil:configurable-nav-keys
Open

Allow any keys to drive navigation#11
spenthil wants to merge 1 commit into
paulbkim-dev:mainfrom
spenthil:configurable-nav-keys

Conversation

@spenthil

@spenthil spenthil commented Aug 7, 2026

Copy link
Copy Markdown

Motivation

Ctrl+h/j/k/l costs real defaults in some setups: Neovim's Ctrl+l clear-and-redraw, and readline's Ctrl+l / Ctrl+k in shell panes (the README already calls this out). Some people also navigate with other chords entirely — I use ctrl+arrow, matching my tmux bindings on servers. This PR makes every key configurable while changing no defaults.

Changes

  • navigate.sh: the key forwarded into a Vim pane now reads HERDR_NAV_KEY_LEFT/DOWN/UP/RIGHT per direction, defaulting to the previously hardcoded ctrl+h/j/k/l.
  • editor/nvim.lua + editor/vim.vim: navigation is exposed as <Plug>(HerdrNavigateLeft/Down/Up/Right). g:herdr_nav_keys replaces any subset of the default keys, and an empty string drops that direction. g:herdr_nav_no_mappings = 1 defines no keys at all, so any binding can drive the <Plug> mappings directly.
  • README.md: a "Custom keys" section documents the three hops that must agree (herdr keybind → forwarded key → editor map), with a complete ctrl+arrow example. One over-long intro sentence is split; no other prose changes.

Compatibility

With nothing set, behavior is identical: same keys, same forwarding. The one observable difference is that :map shows the default keys as <Plug> redirections instead of direct function calls.

Testing

  • navigate.sh against a live herdr 0.7.5 pane running Neovim: a probe mapping in that Neovim recorded the forwarded chord — ctrl+h with nothing set, and ctrl+up with HERDR_NAV_KEY_UP='ctrl+up'.
  • Both editor files in a headless nvim --clean matrix: defaults, custom keys, a dropped direction, and no_mappings, checking the resulting maps with maparg(). A feedkeys() test confirms a custom chord moves between two real splits through the <Plug> chain.

🤖 Generated with Claude Code

herdr side: the key forwarded into a Vim pane is now overridable per
direction via HERDR_NAV_KEY_LEFT/DOWN/UP/RIGHT. The defaults are the
previously hardcoded ctrl+h/j/k/l, so existing setups are unaffected.

editor side (vim.vim + nvim.lua): the four maps now go through
<Plug>(HerdrNavigateLeft/Down/Up/Right). g:herdr_nav_keys replaces any
subset of the default keys, and an empty string drops that direction.
g:herdr_nav_no_mappings=1 defines no keys at all, for binding the <Plug>
mappings directly.

README: new "Custom keys" section documenting the three hops that must
agree, with a full ctrl+arrow example.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant