feat: Add built-in to search keymaps (#191)
* Add built-in to search keymaps * Re-factor maps for cleaner codes Rather than use function to return a results table for various key maps. Assign results the key maps table itself. This makes for cleaner code. * Keymaps: escape termcodes using built-in util * Rename builtin.maps to builtin.keymaps
This commit is contained in:
@@ -345,6 +345,13 @@ require'telescope.builtin'.command_history{}
|
|||||||
|
|
||||||
Search the vim command history.
|
Search the vim command history.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
require'telescope.builtin.maps{}
|
||||||
|
```
|
||||||
|
|
||||||
|
Search on vim key maps.
|
||||||
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require'telescope.builtin'.buffers{
|
require'telescope.builtin'.buffers{
|
||||||
-- Optional
|
-- Optional
|
||||||
|
|||||||
@@ -923,4 +923,33 @@ builtin.marks = function(opts)
|
|||||||
}):find()
|
}):find()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- find normal mode mappings
|
||||||
|
builtin.keymaps = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local modes = {"n", "i", "c"}
|
||||||
|
local keymaps_table = {}
|
||||||
|
for _, mode in pairs(modes) do
|
||||||
|
local keymaps_iter = vim.api.nvim_get_keymap(mode)
|
||||||
|
for _, keymap in pairs(keymaps_iter) do
|
||||||
|
table.insert(keymaps_table, keymap)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
pickers.new({}, {
|
||||||
|
prompt_title = 'Key Maps',
|
||||||
|
finder = finders.new_table {
|
||||||
|
results = keymaps_table,
|
||||||
|
entry_maker = function(line)
|
||||||
|
return {
|
||||||
|
valid = line ~= "",
|
||||||
|
value = line,
|
||||||
|
ordinal = line.lhs .. line.rhs,
|
||||||
|
display = line.mode .. ' ' .. utils.display_termcodes(line.lhs) .. ' ' .. line.rhs
|
||||||
|
}
|
||||||
|
end
|
||||||
|
},
|
||||||
|
sorter = conf.generic_sorter()
|
||||||
|
}):find()
|
||||||
|
end
|
||||||
|
|
||||||
return builtin
|
return builtin
|
||||||
|
|||||||
Reference in New Issue
Block a user