hrsh7th / nvim-cmp

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

if function name is prefixed by `$`, it is not inserted on confirm #930

Open nskhei opened 2 years ago

nskhei commented 2 years ago

FAQ

Issues

Neovim Version

NVIM v0.7.0

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-nvim-lsp'
Plug 'neovim/nvim-lspconfig'
Plug 'L3MON4D3/LuaSnip'
Plug 'saadparwaiz1/cmp_luasnip'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      require('luasnip').lsp_expand(args.body)
    end,
  },
  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true })
  },
  sources = {
    { name = "nvim_lsp" },
  },
}
EOF

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

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

Description

cmp-bug

Steps to reproduce

  1. Create javascript or typescript file
  2. Write a function which name is prefixed by $
  3. Try completion

Expected behavior

Actual behavior

Additional context

No response

hrsh7th commented 2 years ago

It's language server's problem.

nskhei commented 2 years ago

It's language server's problem.

Thank you, I found this does not happen for denols.

I also found that using UltiSnips for snippet.expand solves this problem as a workaround.