[Feature Request]: Load mappings on demand, restore mappings when done debugging
Is your feature request related to a problem? Please describe.
When I installed vimspector, I only really expected to use it every now and again (debugging real-time systems is usually better via a UART and gdb only comes out in desperate cases). The "Human" mappings sounded sensible for general use, but I was then surprised that all my previous F-key mappings had disappeared - I expected them to appear when I first ran vimspector or did a packadd or something like that.
Describe the solution you'd like
Include an autoload command called something like vimspector#LoadMappings "human" (perhaps with a default that can be saved in vimrc) that saves existing F-key mappings (useful reference here) somewhere and then installs the F-key mappings. Also include an autoload command called something like vimspector#UnloadMappings that restores whatever you had before loading vimspector.
Loading mappings could also be automatic when you first run a Vimspector command/function, but I wouldn't mind it being a (single) manual step.
Describe alternatives you've considered
For now, I've removed the g:vimspector_enable_mappings thing from my vimrc, but that means that when I want to debug something I have to do one of:
- Edit vimrc and then restart vim (which loses all the tabs, splits etc)
- Manually do the mappings, then manually undo them when I'm done
- Write my own function to do LoadMappings / UnloadMappings
You can use this https://github.com/puremourning/vimspector?tab=readme-ov-file#custom-mappings-while-debugging
BY default vimspector doesn’t set any mappings unless you ask for them. A hook already exists to set your own custom mappings in debug start/end (I use this myself for some non-Fkey) mappings.
I mean I guess I could move the mapping code to a function you can call with the mode but it’s like 10 LOCs: https://github.com/puremourning/vimspector/blob/5e24df822e278ee79abfc8c7110089a5322d1a3c/plugin/vimspector.vim#L137 and all the PLUG mappings are documented so I’m not seeing this as a priority. Maybe would accept a PR with tests though.