Make it possible to disable or override a mapping
HartBlanc opened this issue · 0 comments
HartBlanc commented
I tried to override the vertical split mapping so that it would open the file in a vertical split right away rather than waiting for the user to manually close vifm.
I achieved this with some hacky config:
local function mappings()
-- make ctrl-v close the file manager and open the file in a split pane. The default behaviour is to only
-- open the split pane once the flie manager has been closed manually by the user.
vim.api.nvim_buf_set_keymap(
0,
"t",
"<c-v>",
'<C-\\><C-n>:lua require("fm-nvim").setMethod("vsplit | edit")<CR>il<cr>',
{ silent = true }
)
end
fm_nvim.setup({
on_open = {
mappings,
},
mappings = {
-- something that I'm unlikely to press so that it is effectively disabled (these mappings are set after on_open
-- so it would override the <c-v> defined in mappings if we didn't set it)
vert_split = "sirerofpuwyq-;ufwyq-;pufyqw-;pufyqw-;",
},
})
This works, but it's a bit messy. Providing an empty string to, or omitting, the vert_spilt
mappings
map entry causes it to error or default to <c-v>
and because the default mappings are set up after on_open
it would override my override.
Adding an override was my use case, but it would also be nice to disable mappings that users have no intention to use as they may conflict with other mappings, and generally create unnecessary noise.