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:
parent
248b4abcfa
commit
b39c708cde
1 changed files with 58 additions and 33 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue