nvim-cmp
nvim-cmp copied to clipboard
Autocompletion in cmdline changes window-local cwd
FAQ
- [X] I have checked the FAQ and it didn't resolve my problem.
Announcement
- [X] I have checked Breaking change announcement.
Minimal reproducible full config
local tmp = '/tmp'
local data = tmp .. '/' .. (vim.env.NVIM_APPNAME or 'nvim')
local package_root = data .. '/site'
local clone_root = package_root .. '/pack/packages/start'
local clone_info = {
{
path = clone_root .. '/cmp-cmdline',
url = 'https://github.com/hrsh7th/cmp-cmdline.git',
},
{
path = clone_root .. '/nvim-cmp',
url = 'https://github.com/hrsh7th/nvim-cmp.git',
},
}
vim.fn.mkdir(clone_root, 'p')
vim.opt.pp:prepend(package_root)
vim.opt.rtp:prepend(package_root)
vim.opt.mousemoveevent = true
for _, info in ipairs(clone_info) do
if not vim.loop.fs_stat(info.path) then
vim.notify('cloning ' .. info.url, vim.log.levels.INFO)
vim.fn.system({ 'git', 'clone', info.url, info.path })
end
end
local cmp = require('cmp')
cmp.setup({})
cmp.setup.cmdline(':', {
enabled = true,
sources = {
{
name = 'cmdline',
option = {
ignore_cmds = {},
},
},
},
})
Description
Local cwd is wrong after restoring session from file if using cmp autocompletion in cmdline.
Steps to reproduce
-
mkdir -p ~/test/a/
-
nvim -u ~/cmp-repro.lua
-
:tcd ~/test/
-
:lcd sub/
-
:mks! ~/session
- Quit nvim, re-enter nvim using
nvim -u ~/cmp-repro.lua -S ~/session
-
:verbose pwd
-->[window] /home/<username>/test
, should be[window] /home/<username>/test/a
Expected behavior
Local working directory should be ~/test/a
Actual behavior
Local working directory is ~/test
Additional context
No response
Have encountered the same problem. Did you find out the root of the problem or solution?