In mini.files how to add a new mapping for synchronizing? #1532
-
Contributing guidelines
Module(s)mini.files QuestionI couldn't find anything, and I'm not super great with Lua. But what I'm wondering is if it's possible to have an additional mapping for synching changes made in mini.files? So instead of hitting An alternative would be to just remap the synch to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Sure, that should be possible by going the same route as this example for making buffer-local mappings. So something like this: vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesBufferCreate',
callback = function(args)
vim.keymap.set('i', '<C-s>', function() MiniFiles.synchronize() end, { buffer = args.data.buf_id })
end,
}) So although this works, it would not be very useful to always stay in Insert mode, as synchronization might rearrange lines according to sorting and put cursor at the file/directory name start. My suggestion would be try and get used to a generally assumed way of making edits in Neovim/Vim: the non-typing activity is usually better to do from Normal mode. There is a reason it is called Normal, as it is assumed for user to stay mostly inside of it during text edits.
I am not sure I understand the problem here. It is possible to create multiple files inside a directory (by adding more than one new line and doing sync after that). So if it is a newly created directory, that would require creating a directory (text edit + sync), navigate inside of it, create more than one file (text edit + sync). FYI, for a single file inside a new directory it is possible to add a line 'new-dir/new-subdir/new-file' and 'mini.files' will create all those new directories and a file. |
Beta Was this translation helpful? Give feedback.
Sure, that should be possible by going the same route as this example for making buffer-local mappings. So something like this:
So although this works, it would not be very useful to always stay in Insert mode, as synchronization might rearrange lines according to sorting and put cursor at the file/directory name start.
My suggestion would be try and get used to a generally assumed way of making edits in Neovim/Vim: the non-typing activity is usually better to do from Normal …