A Neovim plugin that shows upstream references — which files import the current file — in a dedicated buffer with a visual file tree.
- LSP mode: Uses
textDocument/referencesfor precise results. Resolves grouped exports (export { Foo }) to their declarations before querying. - Grep mode: Fast fallback using
grep -rnfor import patterns. No LSP required. - Import chain visualization: Transitively follows references across your history to show the full dependency chain.
- File tree: ASCII tree of all related files with common ancestor detection.
- Parent highlighting: Files that import the current file are highlighted in green.
- Barrel file filtering: Automatically excludes
index.tsbarrel re-exports from results. - History: Tracks the last 20 files you've visited and their references.
- Auto-refresh: Updates on
BufEnterwith debouncing.
{
"Baruch4413/smart-tree.nvim",
config = function()
require("smart-tree").setup()
end,
}Clone into your Neovim packages directory:
git clone git@github.com:Baruch4413/smart-tree.nvim.git \
~/.local/share/nvim/site/pack/plugins/start/smart-tree.nvimThen add to your config:
require("smart-tree").setup()| Command | Description |
|---|---|
:SmartTree |
Toggle the smart-tree buffer |
:SmartTree lsp |
Switch to LSP mode |
:SmartTree grep |
Switch to grep mode |
| Key | Action |
|---|---|
<CR> |
Open file at cursor (jumps to import line) |
q |
Close smart-tree |
m |
Toggle between LSP and grep mode |
R |
Reset history |
require("smart-tree").setup({
auto_refresh = true, -- refresh on BufEnter
debounce_ms = 150, -- debounce delay
lsp_timeout_ms = 3000, -- LSP request timeout
max_history = 20, -- max tracked files
mode = "lsp", -- "lsp" or "grep"
keymaps = {
open = "<CR>",
quit = "q",
toggle_mode = "m",
reset = "R",
},
}) smart-tree [lsp]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
References
MyComponent.tsx ◀
↳ imported by ParentPage.tsx:12
↳ imported by App.tsx:3
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
File Tree
src/components/
├── MyComponent.tsx ◀
├── ParentPage.tsx ← green
└── App.tsx ← green
◀ marks the current file. Parent files (direct importers) are highlighted in green in both sections.
MIT