hrsh7th / nvim-cmp

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

`ghost_text` option causes `vim.lsp.util.parse_snippet` error in newer neovim builds #1735

Closed mtaciano closed 11 months ago

mtaciano commented 11 months ago

FAQ

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'
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" },
  }),
  experimental = {
      ghost_text = true,
  }
}
EOF

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

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

Description

With neovim version 0.10.0, every time the user invokes the completion menu, the following error is thrown:

vim.lsp.util.parse_snippet is deprecated :help deprecated
This feature will be removed in Nvim version 0.11
Press ENTER or type command to continue

Looking at the error message, it indicates that this line is to blame: https://github.com/hrsh7th/nvim-cmp/blob/d3a3056204e1a9dbb7c7fe36c114dc43b681768c/lua/cmp/entry.lua#L127

Steps to reproduce

Open a file and let the LSP for that file type load. After that, type some text so that the ghost text appears.

Expected behavior

No error message is shown.

Actual behavior

An error message is shown for every new buffer.

Additional context

It seems that the function vim.lsp.util.parse_snippet and other util functions are going to be deprecated, see https://github.com/neovim/neovim/commit/195301c60969c7ce97b1ef3a3caaf4965da1abd5.

Shougo commented 11 months ago

Please see this.

https://github.com/hrsh7th/nvim-cmp/pull/1734

mtaciano commented 11 months ago

Closing this issue as it was kind of fixed by https://github.com/hrsh7th/nvim-cmp/pull/1734. Although, as a side effect, the ghost type word doesn't appear anymore. At least no more errors are shown.