Closed
Description
Description
when opening nvim in a folder like nvim \$abc/def
when using vim.g.loaded_netrw = 1 and vim.g.loaded_netrwPlugin = 1
there's an error. I believe it happens because of vim.fn.expand here.
:lua print(vim.fn.expand("/$abc/def"))
returns //def
as seen in the error Can't find directory "/home/adam/Downloads//def"
. Full error is in actual behavior below
Neovim version
NVIM v0.9.0-dev+185-g3de2a7f6d
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Operating system and version
Linux 5.19.16-200.fc36.x86_64
nvim-tree version
Minimal config
vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
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",
"nvim-tree/nvim-tree.lua",
"nvim-tree/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 {}
end
Steps to reproduce
1.mkdir "\$abc/def/" -p
2.nvim -nu /tmp/nvt-min.lua \$abc/def
Expected behavior
no errors
Actual behavior
Error executing vim.schedule lua callback: ...n/site/pack/packer/start/nvim-tree.lua/lua/nvim-tree.lua:231: Vim(cd):E344: Can't find directory "/home/adam/Downloads//def" in cdpath
stack traceback:
[C]: in function 'cmd'
...n/site/pack/packer/start/nvim-tree.lua/lua/nvim-tree.lua:231: in function 'on_enter'
...n/site/pack/packer/start/nvim-tree.lua/lua/nvim-tree.lua:788: in function <...n/site/pack/packer/start/nvim-tree.lua/lua/nvim-tree.lua:787>```