Skip to content

[On windows] Root of nvim-tree changed unexpectedly and buffer not listed by telescope #2961

Closed
@ljie-PI

Description

@ljie-PI

Description

With this change (45a93d9#diff-eeb21711fceb0abba1450bd1adcbecc4fd90cf8ce4d5d7a8233f886c1bebd41fR375), I found it doesn't work well on Windows for 2 cases:

  1. When I open a file from nvim-tree, the root of nvim-tree window changed to the directory of that file
  2. The buffer of this file can not be listed when I use telescope command <cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})<cr>

Neovim version

NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713484068

Operating system and version

Windows 11

Windows variant

Command Prompt

nvim-tree version

2a268f6

Clean room replication

I'm on windows so don't have /tmp/nvt-min.lua.

Pasting my config here:

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

local api_status_ok, nvim_tree_api = pcall(require, "nvim-tree.api")
if not api_status_ok then
  return
end

local function customized_on_attach(bufnr)
  local function opts(desc)
    return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
  end
  -- default mappings
  nvim_tree_api.config.mappings.default_on_attach(bufnr)
  -- custom mappings
  vim.keymap.set('n', 'c', nvim_tree_api.tree.change_root_to_node, opts('CD'))
  vim.keymap.set('n', 'l', nvim_tree_api.node.open.edit, opts('Open'))
  vim.keymap.set('n', '<CR>', nvim_tree_api.node.open.edit, opts('Open'))
  vim.keymap.set('n', 'o', nvim_tree_api.node.open.edit, opts('Open'))
  vim.keymap.set('n', 'h', nvim_tree_api.node.navigate.parent_close, opts('Close Directory'))
  vim.keymap.set('n', 'v', nvim_tree_api.node.open.vertical, opts('Open: Vertical Split'))
end

local keymap = vim.api.nvim_set_keymap
keymap("n", "<leader>e", ":NvimTreeToggle<CR>", { noremap = true, silent = true })

nvim_tree.setup {
  update_focused_file = {
    enable = true,
    update_cwd = true,
  },
  actions = {
    change_dir = {
      enable = false,
    }
  },
  renderer = {
    root_folder_modifier = ":t",
    icons = {
      glyphs = {
        default = "",
        symlink = "",
        folder = {
          arrow_open = "",
          arrow_closed = "",
          default = "",
          open = "",
          empty = "",
          empty_open = "",
          symlink = "",
          symlink_open = "",
        },
        git = {
          unstaged = "",
          staged = "S",
          unmerged = "",
          renamed = "",
          untracked = "U",
          deleted = "",
          ignored = "",
        },
      },
    },
  },
  diagnostics = {
    enable = true,
    show_on_dirs = true,
    icons = {
      hint = "",
      info = "",
      warning = "",
      error = "",
    },
  },
  view = {
    width = 45,
    side = "left",
  },
  on_attach = customized_on_attach,
}

Steps to reproduce

  1. cd C:\Users${username}\AppData\Local\nvim-data\site\pack\packer\start\nvim-tree.lua
  2. nvim .
  3. move to the file lua\nvim-tree\actions\root\change-dir.lua and open it
    image
  4. look at the nvim-tree window, the root changes to lua\nvim-tree\actions\root
    image
  5. and call the list buffer function in telescope, nothing shows up
    image

Expected behavior

No response

Actual behavior

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions