hrsh7th/nvim-cmp

Cmp configured with cmdline breaks scoped working directories

Open

#1425 opened on Feb 5, 2023

View on GitHub
 (6 comments) (0 reactions) (0 assignees)Lua (9,420 stars) (437 forks)batch import
bughelp wantedreproduced

Description

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-cmdline'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true })
  },

  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "buffer" },
  }),
}

                cmp.setup.cmdline(':', {
                    sources = cmp.config.sources({
                        { name = 'path' }
                    }, {
                        {
                            name = 'cmdline',
                            option = {
                                ignore_cmds = { 'Man', '!' }
                            }
                        }
                    })
                })
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').default_capabilities()

require'lspconfig'.cssls.setup {
  capabilities = capabilities,
}
EOF

Description

Strange issue / interaction with scoped working directories when using cmp with cmp.cmdline.

Steps to reproduce

open nvim with provided config above. :e :tcd /home/user/.local :vsp :verbose pwd ([tabpage] /home/user/.local) - correct, the tab working directory is as it is :enew | lcd /home/user/.config :verbose pwd ([window] /home/user/.local) - whereas it should be /home/user/.config, also note verbose prints [window] in front of it which is correct.

NOTE: getcwd() also prints the wrong tab directory (tcd) instead of the local directory (lcd)

Expected behavior

The lcd should be returned as expected.

Actual behavior

The working directory returned is incorrect.

Additional context

No response

Contributor guide