feat(nvim/oil): A keymap to recursively open directories

Because oil.nvim don't group empty directories.

REF: https://github.com/stevearc/oil.nvim/issues/346
REF: https://github.com/stevearc/oil.nvim/pull/452
This commit is contained in:
Ahmad Ansori Palembani 2025-05-27 10:42:42 +07:00
parent 248b4abcfa
commit b39c708cde
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -28,6 +28,31 @@ return {
default_file_explorer = true, default_file_explorer = true,
keymaps = { keymaps = {
["q"] = "actions.close", ["q"] = "actions.close",
["<A-CR>"] = {
desc = "Recursively Open directores",
callback = function()
local oil = require("oil")
local dir = oil.get_current_dir()
local cursor = oil.get_cursor_entry()
local function o()
oil.open(dir .. cursor.name)
vim.wait(50)
dir = oil.get_current_dir()
cursor = oil.get_cursor_entry()
local bn = vim.fn.bufnr()
local lines = vim.api.nvim_buf_line_count(bn)
if lines == 1 and cursor ~= nil and cursor.type == "directory" then
o()
end
end
o()
end,
},
}, },
}) })
end end