Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lua/mini/pick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2200,11 +2200,12 @@ H.picker_advance = function(picker)
vim.schedule(function() vim.api.nvim_exec_autocmds('User', { pattern = 'MiniPickStart' }) end)

local do_match, is_aborted = false, false
local lmap = H.get_lmap()
for _ = 1, 1000000 do
if H.cache.is_force_stop_advance then break end
H.picker_update(picker, do_match)

local char = H.getcharstr(picker.opts.delay.async)
local char = H.getcharstr(picker.opts.delay.async, vim.o.iminsert == 0 and {} or lmap)
if H.cache.is_force_stop_advance then break end

is_aborted = char == nil
Expand Down Expand Up @@ -2860,7 +2861,7 @@ H.picker_get_current_item = function(picker)
end

H.picker_get_register_contents = function(picker)
local register = H.getcharstr(picker.opts.delay.async)
local register = H.getcharstr(picker.opts.delay.async, {})
-- Mimic some "insert object under cursor" behavior of Command-line mode
local expand_var = ({ ['\1'] = '<cWORD>', ['\6'] = '<cfile>', ['\23'] = '<cword>' })[register]
if expand_var then
Expand Down Expand Up @@ -3586,7 +3587,7 @@ H.redraw = function() vim.cmd('redraw') end

H.redraw_scheduled = vim.schedule_wrap(H.redraw)

H.getcharstr = function(delay_async)
H.getcharstr = function(delay_async, lmap)
-- Ensure that redraws still happen
H.timers.getcharstr:start(0, delay_async, H.redraw_scheduled)
H.cache.is_in_getcharstr = true
Expand All @@ -3599,7 +3600,7 @@ H.getcharstr = function(delay_async)
if H.pickers.active ~= nil then main_win_id = H.pickers.active.windows.main end
local is_bad_mouse_click = vim.v.mouse_winid ~= 0 and vim.v.mouse_winid ~= main_win_id
if not ok or char == '' or char == '\3' or is_bad_mouse_click then return end
return char
return lmap[char] or char
end

H.tolower = (function()
Expand Down Expand Up @@ -3681,4 +3682,13 @@ end
-- TODO: Remove after compatibility with Neovim=0.9 is dropped
H.islist = vim.fn.has('nvim-0.10') == 1 and vim.islist or vim.tbl_islist

H.get_lmap = function()
if vim.o.keymap == '' then return {} end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not check 'keymap' option because language mappings can be present even if 'keymap' is not used.

local lmap = {}
for _, map in ipairs(vim.fn.maplist()) do
if map.mode == 'l' then lmap[map.lhs] = map.rhs end
end
return lmap
end

return MiniPick