hrsh7th/nvim-cmp

Cmp configured with cmdline breaks scoped working directories

Open

#1425 aperta il 5 feb 2023

Vedi su GitHub
 (6 commenti) (0 reazioni) (0 assegnatari)Lua (437 fork)batch import
bughelp wantedreproduced

Metriche repository

Star
 (9420 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor