[mini.files]: Enable Window Picker for Splits #1456
-
Contributing guidelines
Module(s)mini.files QuestionI'm wondering if there's a way to configure opening files in a specific split window. I had the plugin https://github.com/s1n7ax/nvim-window-picker enabled when I was using It doesn't seem like there's a way to map functions to the internal keys of Basically: move cursor to the file, press |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sure, this is possible via making custom buffer-local mappings (similar to this code, for example). Something like this should work: require('mini.files').setup({ mappings = { go_in = '', go_in_plug = '' } })
local pick_win_and_go_in = function(close_on_file)
if MiniFiles.get_fs_entry().fs_type == 'file' then
local picked_win_id = require('window-picker').pick_window()
MiniFiles.set_target_window(picked_win_id)
end
MiniFiles.go_in({ close_on_file = close_on_file })
end
vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesBufferCreate',
callback = function(args)
local buf_id = args.data.buf_id
vim.keymap.set('n', 'l', function() pick_win_and_go_in(false) end, { buffer = buf_id })
vim.keymap.set('n', 'L', function() pick_win_and_go_in(true) end, { buffer = buf_id })
end,
}) |
Beta Was this translation helpful? Give feedback.
Sure, this is possible via making custom buffer-local mappings (similar to this code, for example). Something like this should work: