hrsh7th/nvim-cmp

Cmp configured with cmdline breaks scoped working directories

Open

#1,425 建立於 2023年2月5日

在 GitHub 查看
 (6 留言) (0 反應) (0 負責人)Lua (437 fork)batch import
bughelp wantedreproduced

倉庫指標

Star
 (9,420 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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

貢獻者指南