nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua
Other
7.17k stars 609 forks source link

Unable to watch file change unless file operation is done through nvim-tree #1002

Closed Xp-speit2018 closed 2 years ago

Xp-speit2018 commented 2 years ago

OS Operation system's name and version

OS: Manjaro 21.2.3 Qonos
Kernel: x86_64 Linux 5.15.5-arch1-1-surface

Neovim version output of nvim --version

Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Nvim-tree version latest

Describe the bug When I use a to add file or d to remove file, the file tree updates as expected. However, if I use my shell to run touch newfile, the created newfile won't appear in the tree, even if I re-open the directory by nvim .. Here's my nvim-tree.lua:

vim.g.nvim_tree_icons = {
  default = "",
  symlink = "",
  git = {
    unstaged = "",
    staged = "S",
    unmerged = "",
    renamed = "➜",
    deleted = "",
    untracked = "U",
    ignored = "◌",
  },
  folder = {
    default = "",
    open = "",
    empty = "",
    empty_open = "",
    symlink = "",
  },
}

local status_ok, nvim_tree = pcall(require, "nvim-tree")
if not status_ok then
  return
end

local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
if not config_status_ok then
  return
end

local tree_cb = nvim_tree_config.nvim_tree_callback

nvim_tree.setup {
  disable_netrw = true,
  hijack_netrw = true,
  open_on_setup = false,
  ignore_ft_on_setup = {
    "startify",
    "dashboard",
    "alpha",
  },
  auto_close = true,
  open_on_tab = false,
  hijack_cursor = false,
  update_cwd = true,
  update_to_buf_dir = {
    enable = true,
    auto_open = true,
  },
  diagnostics = {
    enable = true,
    icons = {
      hint = "",
      info = "",
      warning = "",
      error = "",
    },
  },
  update_focused_file = {
    enable = true,
    update_cwd = true,
    ignore_list = {},
  },
  system_open = {
    cmd = nil,
    args = {},
  },
  filters = {
    dotfiles = false,
    custom = {},
  },
  git = {
    enable = true,
    ignore = true,
    timeout = 500,
  },
  view = {
    width = 30,
    height = 30,
    hide_root_folder = false,
    side = "left",
    auto_resize = true,
    mappings = {
      custom_only = false,
      list = {
        { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
        { key = "h", cb = tree_cb "close_node" },
        { key = "v", cb = tree_cb "vsplit" },
      },
    },
    number = false,
    relativenumber = false,
  },
  trash = {
    cmd = "trash",
    require_confirm = true,
  },
  quit_on_open = 0,
  git_hl = 1,
  disable_window_picker = 0,
  root_folder_modifier = ":t",
  show_icons = {
    git = 1,
    folders = 1,
    files = 1,
    folder_arrows = 1,
    tree_width = 30,
  },
}

To Reproduce

  1. nvim .
  2. use a terminal emulator or real terminal to create a newfile in current directory, for example touch newfile.js
  3. notice that newfile.js won't appear in tree
  4. close nvim
  5. reopen by nvim .
  6. newfile.js still won't appear in tree
  7. run ls in terminal to confirm that newfile.js lies exactly in cwd...

Expected behavior newfile.js should appear at least after restarting nvim.

kyazdani42 commented 2 years ago

This is expected, the tree does not use watchers on the filesystem. you should use the refresh. Closing this, i expect to implement watchers at some point but there are not a priority rn.