ncm2 / ncm2-ultisnips

44 stars 3 forks source link

Python parameter expansion with LanguageClient #16

Closed GohioAC closed 5 years ago

GohioAC commented 5 years ago

I use ncm2 with LanguageClient-neovim for python autocompletion. But, I am unable to expand function parameters with this setup. It appears to me that LnaguageClient is not sending back any snippets for the functions. Does this require some additional setup?

Minimal init.vim

if &compatible " use Vim settings, rather than Vi
  set nocompatible
endif
filetype plugin indent on " enable file type detection and plugin and indent loading
syntax enable " enable syntax highlighting

call plug#begin('~/.local/share/nvim/plugged')
Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'} " vim client for LSP
Plug 'ncm2/ncm2' " completion engine
Plug 'ncm2/ncm2-ultisnips' " complete snippets
Plug 'roxma/nvim-yarp' " ncm2 dependency
Plug 'sirver/ultisnips' " create and use snippets
Plug 'honza/vim-snippets' " community decided snippets
call plug#end()

" LanguageClient-neovim
let g:LanguageClient_serverCommands = {
  \ 'python': ['pyls'],
  \ }
let g:LanguageClient_diagnosticsEnable = 0

" ncm2
autocmd BufEnter * call ncm2#enable_for_buffer()
set completeopt=menuone,noselect,noinsert
inoremap <expr> <C-j> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <C-k> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <silent> <expr> <CR> pumvisible() ? ncm2_ultisnips#expand_or("\<CR>", 'n') : "\<CR>"

" ultisnips
let g:UltiSnipsExpandTrigger        = "<Plug>(ultisnips_expand)"
let g:UltiSnipsJumpForwardTrigger   = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger  = "<c-k>"
let g:UltiSnipsRemoveSelectModeMappings = 0

screenshot from 2019-01-15 04-59-53

However, parameter expansion works(mostly) out of the box if I use ncm2-jedi as a source instead.

roxma commented 5 years ago

ncm2-jedi and pysl has different implementation.

You need to ask pyls project for the snippet feature. https://github.com/palantir/python-language-server