Skip to content

feat: configurable editor experience for harpoon -e - #8

Open
pilot322 wants to merge 1 commit into
chaitanyabsprip:mainfrom
pilot322:feat/editor-options
Open

feat: configurable editor experience for harpoon -e#8
pilot322 wants to merge 1 commit into
chaitanyabsprip:mainfrom
pilot322:feat/editor-options

Conversation

@pilot322

Copy link
Copy Markdown

Adds two tmux options that customize how the edit popup behaves when $EDITOR is vim or nvim, in order to provide a more similar experience to harpoon:

  • @tmux-harpoon-faithful-vim-controls (bool, default true): remap q -> :q!, :w -> :wq, and <CR> -> jump to the session on the current line, so the edit popup navigates and exits like the rest of the harpoon UI. Set to false to keep stock vim behaviour.
  • @tmux-harpoon-editor-args (string, default empty): extra args appended to the editor invocation (e.g. --clean, -u NONE) for users who want a lighter editor instance for this popup.

Also fixes a quoting bug in _getFZFCmd: the fzf-tmux -p '50%,50%' form passed literal single quotes around the size argument because the caller word-splits the unquoted command. fzf-tmux exits with status 2 and the popup never spawns, breaking harpoon -l on systems that fall back to fzf-tmux (fzf < 0.53).


I made the faithful vim controls the default behavior as it's closest to what the edit popup in harpoon comes with, so users don't have to relearn the window's behavior. I use this window a lot both in vim and in the plugin and it felt a bit awkward.

Adds two tmux options that customise how the edit popup behaves when
`$EDITOR` is vim or nvim:

- `@tmux-harpoon-faithful-vim-controls` (bool, default `true`): remap
  `q` -> `:q!`, `:w` -> `:wq`, and `<CR>` -> jump to the session on the
  current line, so the edit popup navigates and exits like the rest of
  the harpoon UI. Set to `false` to keep stock vim behaviour.
- `@tmux-harpoon-editor-args` (string, default empty): extra args
  appended to the editor invocation (e.g. `--clean`, `-u NONE`) for
  users who want a lighter editor instance for this popup.

Also fixes a quoting bug in `_getFZFCmd`: the `fzf-tmux -p '50%,50%'`
form passed literal single quotes around the size argument because the
caller word-splits the unquoted command. fzf-tmux exits with status 2
and the popup never spawns, breaking `harpoon -l` on systems that fall
back to fzf-tmux (fzf < 0.53).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the harpoon -e edit popup when $EDITOR is vim/nvim by making the popup behavior configurable via tmux options, and fixes an fzf-tmux invocation quoting issue that could prevent the list popup from opening on older fzf versions.

Changes:

  • Fix _getFZFCmd to return a usable fzf-tmux -p 50%,50% command string (without literal single quotes being passed through).
  • Add vim/nvim-specific edit-popup behavior controlled by @tmux-harpoon-faithful-vim-controls and @tmux-harpoon-editor-args.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread harpoon
Comment on lines +141 to +146
# Tmux options (vim/nvim only):
# @tmux-harpoon-faithful-vim-controls bool, default true
# Remap `q` -> :q!, `:w` -> :wq, and <CR> -> jump to session on the
# current line, mirroring how harpoon's UI navigates.
# @tmux-harpoon-editor-args string, default empty
# Extra args appended to the editor command (e.g. `--clean`, `-u NONE`).
Comment thread harpoon
Comment on lines +147 to +148
edit_file() {
cmd="$EDITOR $cachefile"
Comment thread harpoon
Comment on lines +153 to +156
faithful=$(tmux show-option -gqv "@tmux-harpoon-faithful-vim-controls" 2>/dev/null)
[ -z "$faithful" ] && faithful="true"
if [ "$faithful" = "true" ]; then
cmd="$cmd -c \"nnoremap q :q!<CR>\" -c \"cnoreabbrev w wq\" -c \"nnoremap <silent> <CR> :execute '!$0 -s ' . line('.') <bar> q!<CR>\""
Comment thread harpoon
faithful=$(tmux show-option -gqv "@tmux-harpoon-faithful-vim-controls" 2>/dev/null)
[ -z "$faithful" ] && faithful="true"
if [ "$faithful" = "true" ]; then
cmd="$cmd -c \"nnoremap q :q!<CR>\" -c \"cnoreabbrev w wq\" -c \"nnoremap <silent> <CR> :execute '!$0 -s ' . line('.') <bar> q!<CR>\""
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.

2 participants