[Neotree] Add auto expand of empty dirs
This commit is contained in:
parent
e0c1fc4368
commit
c736531a33
@ -8,6 +8,26 @@ return {
|
|||||||
},
|
},
|
||||||
lazy = false, -- neo-tree will lazily load itself
|
lazy = false, -- neo-tree will lazily load itself
|
||||||
config = function()
|
config = function()
|
||||||
|
-- Automatically open up
|
||||||
|
local function toggle_single_item_folders()
|
||||||
|
local nodes = require("neo-tree.sources.filesystem").get_nodes()
|
||||||
|
|
||||||
|
for _, node in ipairs(nodes) do
|
||||||
|
-- Check if the node is a directory
|
||||||
|
if node.type == "directory" then
|
||||||
|
local children = node:get_children()
|
||||||
|
if #children == 1 then
|
||||||
|
-- If it only has one child, make the folder appear stacked
|
||||||
|
node.collapsed = false -- Open the directory automatically
|
||||||
|
else
|
||||||
|
node.collapsed = true -- Keep multi-item directories collapsed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Refresh Neotree to reflect changes
|
||||||
|
require("neo-tree").refresh()
|
||||||
|
end
|
||||||
require("neo-tree").setup({
|
require("neo-tree").setup({
|
||||||
close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab
|
close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab
|
||||||
popup_border_style = "rounded",
|
popup_border_style = "rounded",
|
||||||
@ -173,6 +193,7 @@ return {
|
|||||||
},
|
},
|
||||||
nesting_rules = {},
|
nesting_rules = {},
|
||||||
filesystem = {
|
filesystem = {
|
||||||
|
scan_mode = 'deep',
|
||||||
filtered_items = {
|
filtered_items = {
|
||||||
visible = false, -- when true, they will just be displayed differently than normal items
|
visible = false, -- when true, they will just be displayed differently than normal items
|
||||||
hide_dotfiles = true,
|
hide_dotfiles = true,
|
||||||
@ -204,7 +225,7 @@ return {
|
|||||||
-- -- the current file is changed while the tree is open.
|
-- -- the current file is changed while the tree is open.
|
||||||
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
|
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
|
||||||
},
|
},
|
||||||
group_empty_dirs = false, -- when true, empty folders will be grouped together
|
group_empty_dirs = true, -- when true, empty folders will be grouped together
|
||||||
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
|
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
|
||||||
-- in whatever position is specified in window.position
|
-- in whatever position is specified in window.position
|
||||||
-- "open_current", -- netrw disabled, opening a directory opens within the
|
-- "open_current", -- netrw disabled, opening a directory opens within the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user