ncm2 / ncm2-ultisnips

44 stars 3 forks source link

LSP function parameter expansion doesn't work #19

Open cjun714 opened 5 years ago

cjun714 commented 5 years ago

Plugin can complete function name, but it can't expand any function parameters,. The language is go, using go-langserver as lsp. All plugins and lsp are newest, neovim 0.4.0 on Linuxmint 19.04

I use key '(' to trigger parameter expansion.

Expected behaviour: void foo ----------> void foo( -----------> void foo(a int, b int)

Below setting worked fine before(few months ago), but it can't work any more now.

" vim-plug {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged')

" snippets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'cjun714/vim-snippets-plus'

" lsp
Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' }

" ncm2
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
if !has("nvim")
  Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'ncm2/ncm2-ultisnips'

call plug#end()

" }}}

" SirVer/ultisnips {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:UltiSnipsExpandTrigger='<tab>'
let g:UltiSnipsJumpForwardTrigger='<C-f>'
let g:UltiSnipsJumpBackwardTrigger='<C-h>'

" }}}
" autozimu/LanguageClient-neovim {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> gf :call LanguageClient#textDocument_references()<CR>
nnoremap <leader> rn :call LanguageClient#textDocument_rename()<CR>

let g:LanguageClient_loadSettings = 1
let g:LanguageClient_settingsPath = expand('~/.vim/languageclient.json')

let g:LanguageClient_completionPreferTextEdit = 1 " ?
let g:LanguageClient_diagnosticsEnable = 1
let g:LanguageClient_selectionUI = 'quickfix'
let g:LanguageClient_serverCommands = {}
let g:LanguageClient_serverCommands.go = ['go-langserver']
let g:LanguageClient_serverCommands.rust = ['rls']
let g:LanguageClient_serverCommands.vue = ['vls']
let g:LanguageClient_serverCommands.javascript = ['javascript-typescript-stdio']
let g:LanguageClient_serverCommands.typescript = ['javascript-typescript-stdio']

" }}}
" ncm2/ncm2 {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufEnter *.rs,*.go,*.html,*.ts,*.js,*.css,*.vue,*.md call ncm2#enable_for_buffer()
set shortmess+=c
set completeopt=noinsert,menuone,noselect
au TextChangedI * call ncm2#auto_trigger()

inoremap <c-c> <ESC> " map C-c to trigger InsertLeave autocmd
inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
"inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
"inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

" }}}
" ncm2/ncm2-ultisnips {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" use '(' to trigger snippet expansion
inoremap <silent> <expr> ( ncm2_ultisnips#expand_or("()", 'n')

" imap <c-u> <Plug>(ultisnips_expand)
"let g:UltiSnipsExpandTrigger = "<Plug>(ultisnips_expand)"
let g:UltiSnipsJumpForwardTrigger = "<c-f>"
let g:UltiSnipsJumpBackwardTrigger  = "<c-h>"
let g:UltiSnipsRemoveSelectModeMappings = 0

" }}}

I also use settings in https://github.com/ncm2/ncm2/issues/19#issue-340860094, but it also can't work now.

Please help, thanks a lot!

faulesocke commented 4 years ago

Have exactly the same problem but with Rust instead of go. Not even the settings from ncm2/ncm2#19 did work.

faulesocke commented 4 years ago

Looks like this is an issue with LanguageClient-neovim. Solution:

let g:LanguageClient_hasSnippetSupport = 1