Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

smart-tree.nvim

A Neovim plugin that shows upstream references — which files import the current file — in a dedicated buffer with a visual file tree.

Features

  • LSP mode: Uses textDocument/references for precise results. Resolves grouped exports (export { Foo }) to their declarations before querying.
  • Grep mode: Fast fallback using grep -rn for 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.ts barrel re-exports from results.
  • History: Tracks the last 20 files you've visited and their references.
  • Auto-refresh: Updates on BufEnter with debouncing.

Installation

lazy.nvim

{
  "Baruch4413/smart-tree.nvim",
  config = function()
    require("smart-tree").setup()
  end,
}

Manual

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.nvim

Then add to your config:

require("smart-tree").setup()

Usage

Command Description
:SmartTree Toggle the smart-tree buffer
:SmartTree lsp Switch to LSP mode
:SmartTree grep Switch to grep mode

Buffer keymaps

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

Configuration

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",
  },
})

Buffer layout

 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.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages