Skip to content

Decouple file-explorer from shell + nvim layers; remove orphaned NERDTree config #2

Description

@lukoshkin

Summary

The NERDTree → nvim-tree migration left the file-explorer coupled across two
layers and two plugins
, and left the old NERDTree config orphaned but still
sourced. Switching to another explorer later (neo-tree, oil.nvim, mini.files,
…) currently means editing the shell layer and the Avante integration,
not just the explorer's own spec. This issue tracks decoupling the explorer so
a future switch is a config-only change, plus deleting the dead NERDTree
config.

Context: v <dir> regressed to opening a blank buffer (netrw disabled +
nvim-tree lazy-loaded on keys, so nothing hijacks the directory at startup).
A stopgap fix was added to the shell v() that hardcodes
require('nvim-tree.api').tree.open() — which is itself an example of the
coupling this issue wants to remove.

Steps to reproduce

The coupling is structural, not a runtime crash. To see the blast radius of a
switch:

  1. grep -rIn -e 'nvim-tree' -e 'NvimTree' conf/ (excluding nvim-web-devicons
    and nvim-treesitter, which are unrelated).
  2. Observe explorer-specific references in the shell (aliases-functions.sh)
    and in Avante (ai/avante.lua), not just in the explorer's own spec.

Expected: the explorer plugin is self-contained — switching it touches only
its own spec file (plus, at most, one filetype-name constant).
Actual: a switch touches 4 files across 3 concerns (explorer spec, shell,
AI integration, treesitter filetype guard), and two explorers' configs are
present at once (nvim-tree live in edge/, NERDTree orphaned in legacy
init.vim).

Grounding

Verified facts (read from the code)

Hard coupling — must rewrite on a switch:

  • conf/nvim/edge/lua/user/core/nvim-tree.lua:46,62,12,54,57,81,89 — the
    explorer itself: plugin spec, require("nvim-tree").setup{}, on_attach
    keymaps via require("nvim-tree.api"), the NvimTree-User augroup, and a
    QuitPre autocmd that matches the NvimTree_<tab> buffer name to
    auto-close the last window. Unavoidably explorer-specific.
  • conf/bash/aliases-functions.sh:122v() runs
    vim -c "lua require('nvim-tree.api').tree.open()" on a directory arg. The
    only nvim-tree leak into the shell layer.
  • conf/nvim/edge/lua/user/ai/avante.lua:49,52-53,58,61-62,92 — Avante
    integration: require "avante.extensions.nvim_tree", two keymaps gated on
    ft = "NvimTree", and selector.exclude_auto_select = { "NvimTree" }.
    This is the easy-to-miss one — Avante ships a dedicated nvim-tree
    extension for selecting files into AI context; a target explorer may not
    have an equivalent.

Soft coupling — one-line edits, harmless if left stale:

  • conf/nvim/edge/lua/user/core/treesitter.lua:30-31
    highlight_disable = { NvimTree = true, latex = true } disables TS
    highlighting on the NvimTree filetype. Update the filetype name on switch.

Orphaned legacy (NERDTree, dead weight):

  • conf/nvim/init.vim:10 — still sources conf/nvim/conf/nerdtree.vim.
  • conf/nvim/conf/nerdtree.vim:1,3-4,6-17 — full NERDTree config: Plug 'preservim/nerdtree', <leader>nt/<leader>nf maps, VimEnter
    open-on-directory autocmd, and the close-if-last-window autocmd. Belongs to
    the legacy init.vim path, parallel to the live edge/ Lua config.

Not coupling (false positives, leave alone):

  • nvim-tree/nvim-web-devicons in bufferline.lua:4, lualine.lua:79,
    telescope.lua:18, avante.lua:266, nvim-tree.lua:52 — that's the
    icons library (GitHub org is nvim-tree), not the explorer.
  • All nvim-treesitter* references — different plugin.

Hypothesis (needs confirmation)

  • The cleanest decoupling for the shell layer is to make v() generic
    (vim "$@") and let Neovim own directory-opening via netrw-hijack — every
    major explorer (nvim-tree, neo-tree, oil) supports it; mini.files needs a
    small autocmd. Confirm by: re-enabling netrw hijack + ensuring the explorer
    loads on a directory, then nvim <dir> opens the tree with no shell logic.
  • The Avante coupling cannot be fully removed (it's an inherent
    integration), but it can be isolated to one block so a switch is a single
    localized edit.

Key files

Path Role
conf/nvim/edge/lua/user/core/nvim-tree.lua The explorer spec + setup + keymaps + auto-close autocmd (hard coupling).
conf/bash/aliases-functions.sh:117-129 v() — shell entry point; hardcodes the nvim-tree API on a directory arg (stopgap to decouple).
conf/nvim/edge/lua/user/ai/avante.lua:49-92 Avante ↔ nvim-tree integration (hard coupling; easy to miss).
conf/nvim/edge/lua/user/core/treesitter.lua:30-31 highlight_disable keyed on the NvimTree filetype (soft coupling).
conf/nvim/init.vim:10 Sources the orphaned NERDTree config (legacy path).
conf/nvim/conf/nerdtree.vim Dead NERDTree config to delete.

Run / test commands

  • Audit coupling: grep -rIn -e 'nvim-tree' -e 'NvimTree' conf/ | grep -ivE 'web-devicons|treesitter'
  • Manual check: v ~/some/dir and nvim ~/some/dir → explorer opens rooted at the dir.
  • After legacy removal: nvim starts clean with no missing-source error.

Acceptance criteria

  • Switching the explorer plugin requires editing only its own spec file
    (core/<explorer>.lua) plus at most the one treesitter filetype constant —
    no shell edit required.
  • v <dir> and bare nvim <dir> both open the configured explorer rooted
    at the directory, with no nvim-tree plugin name hardcoded in
    conf/bash/aliases-functions.sh.
  • The Avante ↔ explorer integration is isolated to a single, clearly
    marked block in ai/avante.lua (one place to edit on a switch).
  • conf/nvim/conf/nerdtree.vim is removed and conf/nvim/init.vim no
    longer sources it; launching nvim via the legacy path produces no error.
  • grep -rIn -e 'nvim-tree' -e 'NvimTree' conf/ | grep -ivE 'web-devicons|treesitter'
    returns only the explorer spec file and the (clearly-scoped) Avante block.

Fix directions

  • Shell layer: revert v() to generic vim "$@"; move directory-opening
    into Neovim via the explorer's netrw-hijack (re-enable hijack + load the
    explorer on a directory). Keeps the shell explorer-agnostic forever.
  • Alternative (lighter): keep v() handling dirs but read the open command
    from a single variable (e.g. V_TREE_CMD), so a switch is one shell line.
  • Avante: wrap the nvim-tree extension wiring in one local block /
    helper so a switch is a single localized edit (or guard with pcall so a
    missing extension degrades gracefully).
  • Legacy: delete conf/nvim/conf/nerdtree.vim and drop the source line
    in conf/nvim/init.vim (verify the legacy init.vim path is still wanted at
    all; if not, that's a larger separate cleanup).

References

  • No sibling issues (first issue on this topic).
  • Originating discussion: v <dir> blank-buffer regression and the stopgap
    fix in conf/bash/aliases-functions.sh.

Resolution

Reference this issue in the fix commit(s). The repo's git log uses
imperative, capitalized subjects (e.g. "Add macOS keyboard and shell
support") — match that and mention #<NNN> in the body. After merge, close
#<NNN> with a comment naming the resolving commit(s). Full protocol: see the
issue-fix skill.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions