Mini.files - multiple keymapping #409
-
Hey! Loving the plugin and even though I am really enjoying Oil currently, I really want to switch over to mini.files for various reasons I won't go into detail here. However, I often switch between a custom configured QMK keyboard and my laptop keyboard, hence I have a strong need to configure keymaps for both options. I can't seem to find a way to configure mini.files the same way as I would with my oil.lua config as I will show below, does anyone know of any suitable options for me? Oil.lua config:
keymaps = {
["?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<Right>"] = "actions.select",
["L"] = "actions.select",
["|"] = "actions.select_vsplit",
["-"] = "actions.select_split",
["<C-t>"] = "actions.select_tab",
["p"] = "actions.preview",
["q"] = "actions.close",
["<Esc>"] = "actions.close",
["<C-l>"] = false,
["<Bs>"] = "actions.parent",
["<Left>"] = "actions.parent",
["H"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = "actions.tcd",
["."] = "actions.toggle_hidden",
}, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi!
Yes, everything listed here seems to be possible, albeit with a slightly different workflow. General idea is that there are two ways to customize mappings:
Here is a starting point for you (Edit: use new require('mini.files').setup({
mappings = {
-- Here 'L' will also close explorer after opening file.
-- Switch to `go_in` if you want to not close explorer.
go_in = '',
go_in_plus = 'L',
go_out = 'H',
go_out_plus = '',
-- Will be overriden by manual `<BS>`, which seems wasteful
reset = '',
-- Overrides built-in `?` for backward search
show_help = '?',
},
-- Only automated preview is possible
windows = { preview = true },
})
local go_in_plus = function()
for _ = 1, vim.v.count1 do
MiniFiles.go_in({ close_on_file = true })
end
end
vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesBufferCreate',
callback = function(args)
local map_buf = function(lhs, rhs) vim.keymap.set('n', lhs, rhs, { buffer = args.data.buf_id }) end
map_buf('<CR>', go_in_plus)
map_buf('<Right>', go_in_plus)
map_buf('<BS>', MiniFiles.go_out)
map_buf('<Left>', MiniFiles.go_out)
map_buf('<Esc>', MiniFiles.close)
-- Add extra mappings from *MiniFiles-examples*
end,
}) See |
Beta Was this translation helpful? Give feedback.
-
This is great, but is there a way to do it without needing to redefine and hardcode any functions? Ive tried various versions of this to no avail
|
Beta Was this translation helpful? Give feedback.
Hi!