nvim-tree.lua icon indicating copy to clipboard operation
nvim-tree.lua copied to clipboard

Drive remappings arent taken into account on Windows when setting root

Open tbttfox opened this issue 2 years ago • 2 comments

Description

Many tools (eg. LSP servers) in Windows don't play well with UNC paths, so I have a networked drive mapped to a letter. However, the root detected by nvim-tree is the network path, and files opened through nvim-tree use their network path.

Neovim version

NVIM v0.7.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Operating system and version

Windows 10

nvim-tree version

078a9e5

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      "kyazdani42/nvim-tree.lua",
      "kyazdani42/nvim-web-devicons",
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print "Installing nvim-tree and dependencies."
  vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  require("nvim-tree").setup {
    open_on_setup_file = true,
    update_focused_file = {
      enable = true,
      update_root = true,
      ignore_list = {},
    },
  }
end

Steps to reproduce

  1. Remap a networked path in Windows to a drive letter
  2. nvim Y:\someFile.txt -nu C:\temp\nvt-min.lua
  3. Notice when nvim-tree opens, the root is \\remapped\network\path

Expected behavior

The root path should be Y:\, and paths to files opened from nvim-tree should start with Y:\

Actual behavior

The root path is \\remapped\network\path, and files opened from nvim-tree start with \\remapped\network\path

tbttfox avatar Jul 14 '22 19:07 tbttfox

The nvim-tree team do not have expertise in nor access to a windows environment hence this issue is "PR Please": you'll need to fix this yourself.

It is similar to https://github.com/kyazdani42/nvim-tree.lua/issues/1091 which was resolved via https://github.com/kyazdani42/nvim-tree.lua/pull/1170

A fix for this issue may involve a similar change. Enabling diagnostics logging whilst making the fix would be useful.

Note that making global changes to the way nvim-tree handles its absolute paths for nodes is impractical and undesirable.

alex-courtis avatar Jul 16 '22 02:07 alex-courtis

An interesting test may be to load files via various means e.g. command line, :e, from quickfix list, fugitive, fzf, nvim-tree etc. then inspecting :ls!.

This may not be an nvim-tree problem, but a more nvim windows behaviour that you will always experience when mixing two types of paths.

My opinion: mixing two types of paths will always result in issues; you should pick one and stick to it, ensuring that all your tooling uses the one way.

alex-courtis avatar Jul 16 '22 02:07 alex-courtis

Closing due to inactivity.

alex-courtis avatar Sep 03 '22 03:09 alex-courtis