iTranslated by AI
How to show hidden files in AstroNvim's neo-tree
Introduction
Vim beginner's memo series.
This post introduces how to display hidden files in AstroNvim's neo-tree.
Main Content
In AstroNvim's default settings, dotfiles and gitignored files are hidden in neo-tree, which makes it a bit difficult to use.
I found a related issue here:
It seems that you can display hidden files by adding the following settings to user/init.lua:
return {
plugins = {
["neo-tree"] = {
hide_dotfiles = false,
}
}
}
However, even after adding this setting, hidden files were not displayed.
It turns out that you need to create neo-tree.lua in user/plugins and configure the settings there.
This time, I configured it as follows:
return {
"nvim-neo-tree/neo-tree.nvim",
opts = {
filesystem = {
follow_current_file = { enabled = true },
hijack_netrw_behavior = "open_current",
use_libuv_file_watcher = true,
filtered_items = {
visible = false, -- Whether hidden by default
show_hidden_count = true,
hide_dotfiles = false, -- Whether to hide dotfiles
hide_gitignored = false, -- Whether to hide gitignored files
hide_by_name = {
"node_modules",
"thumbs.db",
},
never_show = {
".git",
".DS_Store",
".history",
},
},
},
},
}
Now, hidden files are displayed. Instead of setting hidden files to be visible by default, I handled it by excluding dotfiles and gitignored files from the hiding criteria.
Conclusion
That's it for how to display hidden files in AstroNvim's neo-tree.
It seems better not to touch ~/.config/nvim/lua/plugins too much.
Discussion