-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor map implementation and restore which-key compatibility #1029
Refactor map implementation and restore which-key compatibility #1029
Conversation
Should also restore compatibility with idea-which-key
E.g. `map foo bar` and `vmap foo baz` would only output one map for `foo` when calling `:map`. Now it will output all maps that match the ex command's modes. This change also improves the marker characters in the first column of map output.
Also supports `mapclear!` and `unmap!` Moves parsing of the bang modifier to the parser so we can tell the difference between `map! foo bar` and `map ! foo bar`
Support for sunmap and smapclear already exists, and vmap would introduce a Select mode map. Fixes VIM-2260
Fixes VIM-2981
Allows iterating the trie entries without having to create a list or create a list for each entry's keystrokes.
@@ -31,7 +31,7 @@ import javax.swing.KeyStroke | |||
/** | |||
* @author vlan | |||
*/ | |||
@ExCommand(command = "map,nm[ap],vm[ap],xm[ap],smap,om[ap],im[ap],lm[ap],cm[ap],no[map],nn[oremap],vn[oremap],xn[oremap],snor[emap],ono[remap],no[remap],ino[remap],ln[oremap],cno[remap]") | |||
@ExCommand(command = "map,nm[ap],vm[ap],xm[ap],smap,om[ap],im[ap],lm[ap],cm[ap],nn[oremap],vn[oremap],xn[oremap],snor[emap],ono[remap],no[remap],ino[remap],ln[oremap],cno[remap]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened to nomap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a Vim command! There's nmap
and noremap
but no nomap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh! I can't track the change again, but this is funny :D
This PR restores compatibility with idea-which-key, which was broken due to changes to
CommandPartNode
in #979.The
CommandPartNode<T>
classes have been deprecated and reimplemented in terms of a newKeyStrokeTrie<T>
class, that efficiently maps sequences ofKeyStroke
to dataT
. The trie structure is used to store and look up the builtin Vim commands (represented by aT
ofLazyVimCommand
). TheCommandPartNode
API is restored to how it was before #979, and should work with the last released version of which-key.It would be appropriate for which-key to migrate to the new API, which can provide more efficient lookup and iteration.
The new trie structure is now also used for user maps, simplifying and optimising storage and lookup of both finished key sequences and prefixes. While refactoring handling of the
map
commands, several fixes have been made:vmap
for Visual + Select,map
for Normal, Visual, Select and Op-pending. The maps will now have the proper character indicator(s), especially when a map is made in multiple modes and then removed in one, e.g.map foo bar
followed bysunmap foo
will now outputnox foo bar
map foo
will show all maps beginning withfoo
instead of creating a map fromfoo
to<Nop>
) - VIM-2981map!
,unmap!
andmapclear!
to add a map in Insert+Command-line modessmap
andsnoremap
.sunmap
was already supported, and mapping to Select mode was already possible withvmap
- VIM-2260The support for
map!
required adding the "bang modifier" to the parser, rather than relying on the first character of the trailing string argument - this is required to tell the difference betweenmap! foo bar
andmap ! foo bar
.The trie is also used in the NERDTree extension