Show gitignored files in nvim-tree and follow the open buffer
Two nvim-tree defaults that were quietly getting in the way.
filters.git_ignored defaults to true, so gitignored files are hidden. The
symptom was .env being absent from a project while .env.example sat right
there, which reads as a dotfile filter but is not: filters.dotfiles is already
false, so dotfiles show. The filter is git-aware, and .env was simply reported
ignored. Verified in a throwaway repo ignoring .env and vendor/ — both appear
now, and neither did before, with the ignored glyph to distinguish them.
The trade-off is real and is the reason for the default: vendor/ and
node_modules/ now show too. filters.exclude = { '.env' } was the narrower
option, exempting one name while keeping the rest hidden. Chose the broad
setting deliberately; `I` in the tree hides them again per session.
update_focused_file.enable defaults to false, so the tree never moved when a
file was opened from fzf-lua. Enabling it reveals the current buffer on
BufEnter, uncollapsing folders to reach it. Verified on a nested fixture:
opening src/deep/nested/target.php expanded all three folders and put the tree
cursor on the file. Focus stays in the file window, so it reveals rather than
steals, and it follows every buffer switch, not just fzf-lua.
Left update_root off. It would re-root the tree at files outside the current
root, which makes the tree wander into vendor/ — worse now that ignored files
are visible and easier to open by accident.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f5ae360e7e
commit
dda3868321
2 changed files with 12 additions and 0 deletions
|
|
@ -47,6 +47,12 @@ machine gets the same set.
|
||||||
not shift the text sideways.
|
not shift the text sideways.
|
||||||
- **netrw is disabled** and nvim-tree takes over directory buffers, so `nvim .`
|
- **netrw is disabled** and nvim-tree takes over directory buffers, so `nvim .`
|
||||||
opens the tree rather than netrw. The tree opens on the **right**.
|
opens the tree rather than netrw. The tree opens on the **right**.
|
||||||
|
- **The tree shows gitignored files**, unlike nvim-tree's default — so `.env` is
|
||||||
|
visible, at the cost of `vendor/`, `node_modules/` and friends also showing.
|
||||||
|
`I` in the tree hides them again for the session.
|
||||||
|
- **The tree follows the current buffer**, expanding folders to reveal whatever
|
||||||
|
you open — including files opened from fzf-lua. It does not change the tree
|
||||||
|
root to do so, so opening a file from outside the root won't reveal it.
|
||||||
- **Diagnostic signs are letters** (`E` `W` `I` `H`) rather than icons, and do
|
- **Diagnostic signs are letters** (`E` `W` `I` `H`) rather than icons, and do
|
||||||
not update while you are in insert mode.
|
not update while you are in insert mode.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@ vim.pack.add({ 'https://github.com/nvim-tree/nvim-tree.lua' })
|
||||||
|
|
||||||
require('nvim-tree').setup({
|
require('nvim-tree').setup({
|
||||||
view = { side = 'right' },
|
view = { side = 'right' },
|
||||||
|
-- nvim-tree hides gitignored files by default; show them, so things like
|
||||||
|
-- .env are visible. `I` in the tree toggles this back off per session.
|
||||||
|
filters = { git_ignored = false },
|
||||||
|
-- Reveal the current buffer in the tree on BufEnter, expanding folders to
|
||||||
|
-- get to it, so opening a file from fzf-lua moves the tree with you.
|
||||||
|
update_focused_file = { enable = true },
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>e', '<Cmd>NvimTreeToggle<CR>', { desc = 'Toggle file tree' })
|
vim.keymap.set('n', '<leader>e', '<Cmd>NvimTreeToggle<CR>', { desc = 'Toggle file tree' })
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue