Support Dictionary-function elements within the description dictionary #209
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In writing a C# layer for space-vim, I wanted to overlap/replace/augment the '+lsp' key mappings.
EDIT2: For example, in space-vim the hotkey sequence ' lgd' is '+lsp/+goto/definition' using the existing '+lsp' keymappings using the LSP Client as configured in space-vim, but in *.cs files ' lgd' should use OmniSharp-vim (in the C# space-vim layer) to do the same. OmniSharp-vim isn't an LSP Client (it doesn't use the language server protocol (LSP)) but does many of the same things with a language server, so it makes sense to use the same hotkeys.
The most convenient way I thought to do this was to use a dictionary-function as an element within the vim-which-key description dictionary (see
:help dictionary-function
). May have pros/cons compared to the technique of BufEnter/BufLeave in #132 and perhaps #48.The dictionary-function can return a different mapping depending on e.g. the
&filetype
.Example:
EDIT: Very simple changes in vim-which-key.
V
had to be capitalized so as lower-case variable names can't refer to a funcref. And if V was a funcref it had to be called with V() and the result of that dictionary-function assigned to the right location in s:runtime for processing (calculating layout and etc).TODO: I can put a simpler example in the wiki and make a new FAQ entry in the README.md.