nvim-cmp icon indicating copy to clipboard operation
nvim-cmp copied to clipboard

Accepted completion triggers new completion

Open Theo-Steiner opened this issue 3 years ago • 0 comments

FAQ

  • [X] 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 "williamboman/nvim-lsp-installer"
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
require("nvim-lsp-installer").setup({ensure_installed = {"svelte"}})
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 = {
    { name = "nvim_lsp" },
    { name = "buffer" },
    { name = "svelte" },
  },
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())

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

Description

Accepting a completion from the svelte language server emmet plugin ending with a trigger character (> in this case) this immediately triggers a second completion. annoying_completion This is extremely annoying because the natural workflow after accepting the emmet expansion of <div>|</div> is hitting enter, however due to this behavior one ends up inserting a redundant closing tag.

Steps to reproduce

Open temp.svelte in neovim nvim -u ~/cmp-repro.vim temp.svelte type div to get the completion proposal by emmet of <div></div> immediately get another closing </div> proposed by the same language server.

Expected behavior

In vs code, after accepting the emmet expansion, no closing is suggested and one can just hit enter and comfortably edit the content of the

tag.

Actual behavior

an infinite amount of </div>'s are completed, since </div> triggers itself by ending with the trigger character of >

I think this is quite the problem, because the svelte ls uses https://github.com/Microsoft/vscode-html-languageservice internally and that is probably the most popular html lsp, and it has the same problem.

Additional context

No response

Theo-Steiner avatar Jun 29 '22 09:06 Theo-Steiner