How to disable picker's default keymap? #2514
Unanswered
ZhiyuanLck
asked this question in
Q&A
Replies: 1 comment 1 reply
|
You can either disable the buffer-local keymap for both modes, which results in the default behavior: picker = {
win = {
input = {
keys = {
['<C-u>'] = false,Or create an action to map different actions to each mode: -- nvim -u repro.lua repro.lua
-- :lua Snacks.picker.files()
-- Type '12345'
-- <C-u>
-- repro.lua
vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system 'curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua')()
require('lazy.minit').repro {
spec = {
{
'folke/snacks.nvim',
opts = {
picker = {
actions = {
smart_ctrl_u = function(picker)
local mode = vim.fn.mode()
if mode == 'i' then
local key = vim.api.nvim_replace_termcodes('<C-u>', true, false, true)
vim.api.nvim_feedkeys(key, 'n', false)
end
if mode == 'n' then
picker:action 'list_scroll_up'
end
end,
},
win = {
input = {
keys = {
['<C-u>'] = { 'smart_ctrl_u', mode = { 'i', 'n' } },
},
},
},
},
},
},
},
} |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I want to use
<C-U>to clear the input line in insert mode, but currently it has been mapped tolist_scroll_up.I tried to override the mapping with the following code, aiming to restore the original behavior. However, it seems to result in infinite recursion:
All reactions