diff options
| author | Crony Akatsuki <crony@cronyakatsuki.xyz> | 2026-01-01 13:55:19 +0100 |
|---|---|---|
| committer | Crony Akatsuki <crony@cronyakatsuki.xyz> | 2026-01-01 13:55:19 +0100 |
| commit | 494ddcf9850a9e425c6c15396a5b322001d3f83c (patch) | |
| tree | 2bad558af86f20de3d836a3db57bb31ce60252c3 /lua/plugins/mini/files.lua | |
| parent | 8d49f9b18dddcd2d4fa966227db70fb2c710e383 (diff) | |
| download | nvim-494ddcf9850a9e425c6c15396a5b322001d3f83c.zip nvim-494ddcf9850a9e425c6c15396a5b322001d3f83c.tar.gz | |
feat(mini): modularize the config a bit.
Diffstat (limited to 'lua/plugins/mini/files.lua')
| -rw-r--r-- | lua/plugins/mini/files.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lua/plugins/mini/files.lua b/lua/plugins/mini/files.lua new file mode 100644 index 0000000..4285838 --- /dev/null +++ b/lua/plugins/mini/files.lua @@ -0,0 +1,37 @@ +-- super simple but amazing file manager +require("mini.files").setup() + +-- setup simple function for toggling mini.files +local minifiles_toggle = function(...) + if not MiniFiles.close() then MiniFiles.open(...) end +end + +-- Set focused directory as current working directory +local set_cwd = function() + local path = (MiniFiles.get_fs_entry() or {}).path + if path == nil then return vim.notify('Cursor is not on valid entry') end + vim.fn.chdir(vim.fs.dirname(path)) +end + +-- Yank in register full path of entry under cursor +local yank_path = function() + local path = (MiniFiles.get_fs_entry() or {}).path + if path == nil then return vim.notify('Cursor is not on valid entry') end + vim.fn.setreg(vim.v.register, path) +end + +-- Open path with system default handler (useful for non-text files) +local ui_open = function() vim.ui.open(MiniFiles.get_fs_entry().path) end + +vim.api.nvim_create_autocmd('User', { + pattern = 'MiniFilesBufferCreate', + callback = function(args) + local b = args.data.buf_id + vim.keymap.set('n', 'g~', set_cwd, { buffer = b, desc = 'Set cwd' }) + vim.keymap.set('n', 'gX', ui_open, { buffer = b, desc = 'OS open' }) + vim.keymap.set('n', 'gy', yank_path, { buffer = b, desc = 'Yank path' }) + end, +}) + +-- setup keybinding for mini.files +vim.keymap.set("n", "<Leader>e", function() minifiles_toggle() end, { desc = "Toggle mini.files explorer" }) |
