[mini.files] Jump/select current focused buffer #1589
-
Contributing guidelines
Module(s)mini.files QuestionI'm trying to create a keymap to jump to the current buffer in the MiniFiles navigation. My idea would be to open Mini.Files on the root directory, with 'persistence', and have a keymap that updates the MiniFIles window to point to the current buffer (and updates the 'last used state' when the Mini window is closed). vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesBufferCreate',
callback = function(args)
local mini_buf = args.data.buf_id
local src_file = vim.api.nvim_buf_get_name(args.buf)
vim.keymap.set('n', ',', function()
MiniFiles.refresh({...}) -- How can I update the current position?
end, { buffer = mini_buf, desc = 'Jump to current buffer' })
end,
}) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Sorry, I don't think I understand the issue/idea of "does not 'persist'" here. Could you elaborate about your use case with exact steps (preferably with screencast)? Starting explorer with |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response. With persists, i meant that it keeps the 'last used state'. Idea is as following: I want to open MiniFiles with |
Beta Was this translation helpful? Give feedback.
That is relatively straightforward
set_branch()
and most effort is spent into getting the data for what is "current file" (i.e. the file for the buffer that is displayed in the window which was current when explorer opened). So something like this: