whonore / Coqtail

Interactive Coq Proofs in Vim
MIT License
274 stars 34 forks source link

Call a user-specified hook function when defining keybindings #339

Closed jesboat closed 9 months ago

jesboat commented 9 months ago

This serves two purposes. First, it allows a user to define additional keybindings for commands without removing the standard <Leader>cXXX bindings. Second, it allows those bindings to be active specifically in Coqtail-managed buffers.

jesboat commented 9 months ago

I use this for:

function CoqtailHookDefineMappings()
  imap <buffer> <S-Down> <Plug>CoqNext
  imap <buffer> <S-Left> <Plug>CoqToLine
  imap <buffer> <S-Up> <Plug>CoqUndo
  nmap <buffer> <S-Down> <Plug>CoqNext
  nmap <buffer> <S-Left> <Plug>CoqToLine
  nmap <buffer> <S-Up> <Plug>CoqUndo
endfunction

It lets me use the key mappings I have muscle memory for (from the Coq plugin I used 3 iterations ago) in all Coq-related buffers, including panels, while still preserving the default Coqtail bindings.