hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.47k stars 370 forks source link

Autocompletion in cmdline changes window-local cwd #1760

Open Bekaboo opened 7 months ago

Bekaboo commented 7 months ago

FAQ

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

  1. mkdir -p ~/test/a/
  2. nvim -u ~/cmp-repro.lua
  3. :tcd ~/test/
  4. :lcd sub/
  5. :mks! ~/session
  6. Quit nvim, re-enter nvim using nvim -u ~/cmp-repro.lua -S ~/session
  7. :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

DeadlySquad13 commented 5 months ago

Have encountered the same problem. Did you find out the root of the problem or solution?