diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-11-09 18:16:49 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-11-09 21:34:04 +0800 |
commit | 2dfcd5a22b8f26091aa7398fdb8b0ea70ed7b28d (patch) | |
tree | 33540db6f3104e7844ac05fdeb332fe64b046a3e /runtime | |
parent | a4b80c71eae09a5f6f76bce46be46efd247c7223 (diff) | |
download | rneovim-2dfcd5a22b8f26091aa7398fdb8b0ea70ed7b28d.tar.gz rneovim-2dfcd5a22b8f26091aa7398fdb8b0ea70ed7b28d.tar.bz2 rneovim-2dfcd5a22b8f26091aa7398fdb8b0ea70ed7b28d.zip |
vim-patch:8.2.4820: not simple programmatic way to find a specific mapping
Problem: Not simple programmatic way to find a specific mapping.
Solution: Add getmappings(). (Ernie Rael, closes vim/vim#10273)
https://github.com/vim/vim/commit/659c240cf769925ff432b88df8719e7ace4629b0
Co-authored-by: Ernie Rael <errael@raelity.com>
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/builtin.txt | 12 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 1 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 14 |
3 files changed, 25 insertions, 2 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 06e6be41bc..6b34a49891 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -2612,6 +2612,16 @@ getloclist({nr} [, {what}]) *getloclist()* echo getloclist(5, {'filewinid': 0}) < +getmappings() *getmappings()* + Returns a |List| of all mappings. Each List item is a |Dict|, + the same as what is returned by |maparg()|, see + |mapping-dict|. + + Example to show all mappings with "MultiMatch" in rhs: > + echo getmappings()->filter({_, m -> + \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0 + \ }) + getmarklist([{buf}]) *getmarklist()* Without the {buf} argument returns a |List| with information about all the global marks. |mark| @@ -4161,7 +4171,7 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()* When {dict} is there and it is |TRUE| return a dictionary containing all the information of the mapping with the - following items: + following items: *mapping-dict* "lhs" The {lhs} of the mapping as it would be typed "lhsraw" The {lhs} of the mapping as raw bytes "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index c8b31b2d5b..9fe81f56b6 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1012,6 +1012,7 @@ Mappings and Menus: *mapping-functions* digraph_getlist() get all |digraph|s digraph_set() register |digraph| digraph_setlist() register multiple |digraph|s + getmappings() get list of all mappings hasmapto() check if a mapping exists mapcheck() check if a matching mapping exists maparg() get rhs of a mapping diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 817841eb46..f54606b225 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -3175,6 +3175,18 @@ function vim.fn.getline(lnum, end_) end --- @return any function vim.fn.getloclist(nr, what) end +--- Returns a |List| of all mappings. Each List item is a |Dict|, +--- the same as what is returned by |maparg()|, see +--- |mapping-dict|. +--- +--- Example to show all mappings with "MultiMatch" in rhs: > +--- echo getmappings()->filter({_, m -> +--- \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0 +--- \ }) +--- +--- @return any +function vim.fn.getmappings() end + --- Without the {buf} argument returns a |List| with information --- about all the global marks. |mark| --- @@ -5022,7 +5034,7 @@ function vim.fn.map(expr1, expr2) end --- --- When {dict} is there and it is |TRUE| return a dictionary --- containing all the information of the mapping with the ---- following items: +--- following items: *mapping-dict* --- "lhs" The {lhs} of the mapping as it would be typed --- "lhsraw" The {lhs} of the mapping as raw bytes --- "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate |