vim-lsc icon indicating copy to clipboard operation
vim-lsc copied to clipboard

Improve handling of key mapping

Open gpanders opened this issue 5 years ago • 3 comments

  • Only map keys when server is successfully initialized or is already running. This prevents the scenario where LSC still maps keys even if the server fails to initialize (in which case the key mappings are useless).

  • Unmap keys when the server shuts down. Similar to point 1, if the user runs :LSClientDisable then the LSC mappings should be removed.

gpanders avatar Aug 10 '20 20:08 gpanders

This is an interesting feature, it goes against my personal workflow but I'm curious to try it out.

Are there specific keys that you want to be able to use their default behavior when the server isn't running?

I typically rely on the error that a server isn't running to recognize what is happening, I worry that if a server dies (and I don't notice the error about it) and I try a keybind it will be more confusing to have it unmapped... I'll give this a try and see how it feels though.

natebosch avatar Aug 28 '20 23:08 natebosch

The main reason I find this useful is in two scenarios:

  1. I do a lot of Python development and, therefore, use many Python virtual environments. I don't always have the Python language server installed in a new virtual env, nor do I always want it (sometimes I'm just doing quick one-off edits and don't need a whole LS). In this case, it's not an error that the server couldn't be started, and I don't want the mappings to be activated when they don't do anything

  2. Similarly, it's also common for me (and for others, I think) to use the same Vim configuration across multiple server machines, not all of which will have the requisite LSP server software installed. In those cases, I don't necessarily want to modify the vim-lsc config on each and every machine to reflect what is present on the machine; rather, I'd just want vim-lsc to "fail gracefully" in the cases where the LSP server isn't installed.

Are there specific keys that you want to be able to use their default behavior when the server isn't running?

If the server isn't running, then I want <C-]> to maintain its default behavior of jumping to a tag and I would want to keep whatever value of keywordprg was set by the filetype plugin (instead of using :LSClientShowHover).

gpanders avatar Aug 29 '20 14:08 gpanders

Hi Nate, I'm wondering if you've had another chance to review this?

I ran into this issue again recently while working in the Linux kernel source code. vim-lsc started up with the clangd language server; however, I had a tags file generated for the sources and wanted to use that instead. Running :LSClientDisable currently does not also unmap the buffer local mappings, so every time I opened a new buffer I had to run :LSClientDisable followed by :nunmap <buffer> <C-]> so that I could utilize the tags file.

gpanders avatar Feb 12 '21 16:02 gpanders