Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support neosnippet for function arguments completion #396

Closed
xu-cheng opened this issue Apr 23, 2018 · 25 comments
Closed

Support neosnippet for function arguments completion #396

xu-cheng opened this issue Apr 23, 2018 · 25 comments

Comments

@xu-cheng
Copy link
Contributor

Summary

It seems that LanguageClient-neovim does not work well with neosnippet for function arguments completion.

Reproduction

  • neovim/vim version (nvim --version or vim --version):
NVIM v0.3.0-1011-gd05712fbe
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -I/tmp/neovim-20180422-21487-1xs1k7o/build/config -I/tmp/neovim-20180422-21487-1xs1k7o/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20180422-21487-1xs1k7o/build/src/nvim/auto -I/tmp/neovim-20180422-21487-1xs1k7o/build/include
Compiled by chengxu@Chengs-MacBook-Pro.local

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-d05712f_1/share/nvim"

Run :checkhealth for more info
  • This plugin version (git rev-parse --short HEAD): b96f442
  • This plugin's binary version (bin/languageclient --version):
languageclient 0.1.70 6e901906a6b63e074d043b59fe2d44107d5ad792
  • Minimal vimrc content.
call plug#begin('~/.local/share/nvim/plugged')

Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'

call plug#end()

augroup filetype_rust
    autocmd!
    autocmd BufReadPost *.rs setlocal filetype=rust
augroup END

" Always draw sign column. Prevent buffer moving when adding/deleting sign.
set signcolumn=yes

let g:LanguageClient_serverCommands = {
    \ 'rust': ['rustup', 'run', 'stable', 'rls'],
    \ }
let g:LanguageClient_loggingLevel = 'DEBUG'

let g:deoplete#enable_at_startup = 1
let g:neosnippet#enable_completed_snippet = 1
let g:neosnippet#enable_snipmate_compatibility = 1
  • Language server link and version:
rls-preview 0.125.1-stable (cebf188 2018-03-19)
  • Steps to reproduce the issue from clean state
    1. Try to complete any function. For example, String::from in the rust.

Current Behavior

It will autocomplete String::from(${1:s}) with the cursor in the end of the line.

Expected Behavior

It should trigger neosnippet to expand each arguments in the function.

@autozimu
Copy link
Owner

Kind of duplicate with #379.

@glepnir
Copy link

glepnir commented Jan 13, 2019

I got the same problem ,Is there any solution?

@andersevenrud
Copy link

@PendragonSaber I've switched to https://github.com/neoclide/coc.nvim and it seems to work a lot better (even without neosnippet)

@glepnir
Copy link

glepnir commented Jan 13, 2019

@PendragonSaber I've switched to https://github.com/neoclide/coc.nvim and it seems to work a lot better (even without neosnippet)

I have tried it, but there are some problems with the configuration, I can't jump the code block.

@Shougo
Copy link

Shougo commented Jan 14, 2019

It may fixes the problem.

autocmd CompleteDone * call neosnippet#complete_done()

I think LanguageClient-neovim should use userdata instead of word for snippet.

@glepnir
Copy link

glepnir commented Jan 15, 2019

It may fixes the problem.

autocmd CompleteDone * call neosnippet#complete_done()

I think LanguageClient-neovim should use userdata instead of word for snippet.

thanks i will try it

@rraks
Copy link

rraks commented Jan 23, 2019

autocmd CompleteDone * call neosnippet#complete_done()

After implementing this, completing class snippet becomes like this

classmethod(:call 69_snippets_expand_or_jump('classmethod',12)
)<2>

@Shougo
Copy link

Shougo commented Jan 24, 2019

@rraks It must be reproduce-able for other people.
Please upload the minimal vimrc and the reproduce instructions.

@Shougo
Copy link

Shougo commented Jan 26, 2019

I have added LanguageClient-neovim support in neosnippet.

It fixes #379 and #396 problems.
Please test it.

@mikn
Copy link

mikn commented Jan 26, 2019

@Shougo is there any configuration required to make it work?

@Shougo
Copy link

Shougo commented Jan 27, 2019

Nothing. But please use the latest version of neosnippet plugin.

@jubnzv
Copy link

jubnzv commented Jan 27, 2019

@Shougo looks like it works, but I found a strange behavior. After expanding a function I got snippet in the following format:

fun1(<`1:int a`>, <`2:int b`>, <`3:int c`>)<|0|>  

I can move between 1-3 elements (function arguments) with neosnippet_expand_or_jump, but how can I get to leading <|0|>? May be related with Shougo/neosnippet.vim#451, but suggested solution doesn't works.

neosnippet

@Shougo
Copy link

Shougo commented Jan 28, 2019

@jubnzv Please upload the minimal vimrc with the reroduce-able instructions like this issue.
I will test it later.

@Shougo
Copy link

Shougo commented Jan 28, 2019

If not, I cannot help you.

@Shougo
Copy link

Shougo commented Jan 28, 2019

It should be jumped to the last of neosnippet_expand_or_jump.

@jubnzv
Copy link

jubnzv commented Jan 28, 2019

@Shougo Thank you for your reply. Here is minimal vimrc; this issue can be reproduced like on my screencast from previous post:

  1. Start typing function name; select deoplete suggestion
  2. Use <A-l> to navigate through function arguments. When you reach last argument, you got leading zero and the end of function.

My environment: latest versions of related vim plugins; neovim 0.3.4, cquery language server.

init.vim

call plug#begin('~/.local/share/nvim/plugged')
Plug 'https://github.com/Shougo/neosnippet.vim'
Plug 'https://github.com/Shougo/neosnippet-snippets'
Plug 'https://github.com/Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'autozimu/LanguageClient-neovim', {
  \ 'branch': 'next',
  \ 'do': 'bash install.sh',
  \ }
call plug#end()

set hidden
filetype plugin indent on
syntax enable
let g:python3_host_prog  = '/usr/bin/python3.6'

" Deoplete
let g:deoplete#enable_at_startup = 1
let g:deoplete#auto_complete_start_length = 1
let g:deoplete#enable_smart_case = 1
call deoplete#custom#source('LanguageClient',
            \ 'min_pattern_length',
            \ 2)
inoremap <expr><A-q> pumvisible() ? deoplete#mappings#close_popup() : "\<CR>"
inoremap <expr><A-j> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr><A-k> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr><A-o> deoplete#mappings#manual_complete()

" neosnippet
imap <A-l> <Plug>(neosnippet_expand_or_jump)
smap <A-l> <Plug>(neosnippet_expand_or_jump)
xmap <A-l> <Plug>(neosnippet_expand_target)
if has('conceal')
set conceallevel=2 concealcursor=niv

endif

" LanguageClient
let g:LanguageClient_loggingLevel = 'DEBUG'
let g:LanguageClient_settingsPath = '~/.config/nvim/settings.json'
let g:LanguageClient_loggingFile='/tmp/lc.log'
let g:LanguageClient_serverCommands = {
  \ 'cpp': ['/usr/local/bin/cquery', '--log-file=/tmp/cquery.log'],
  \ 'c': ['/usr/local/bin/cquery', '--log-file=/tmp/cquery.log'],
  \ }
let g:LanguageClient_rootMarkers = {
  \ 'cpp': ['compile_commands.json', 'build'],
  \ 'c': ['compile_commands.json', 'build'],
  \ }
let g:LanguageClient_autoStart = 0
let g:LanguageClient_hasSnippetSupport = 1
nnoremap <F5> :call LanguageClient_contextMenu()<CR>

@Shougo
Copy link

Shougo commented Jan 28, 2019

@rraks

After implementing this, completing class snippet becomes like this

Confirmed. It is conflict of autocmd CompleteDone * call neosnippet#complete_done().
Please disable it.

@Shougo
Copy link

Shougo commented Jan 28, 2019

@jubnzv Reproduced. I have fixed the problem in the latest version of neosnippet.

@autozimu I think the issue can be closed.

@Shougo
Copy link

Shougo commented Jan 28, 2019

@rraks I have added g:neosnippet#enable_complete_done. Please use it instead.

@autozimu
Copy link
Owner

@Shougo Thanks!

@autozimu autozimu mentioned this issue Jan 29, 2019
@autozimu
Copy link
Owner

Verified. Closing.

@jubnzv
Copy link

jubnzv commented Jan 29, 2019

@Shougo Shougo/neosnippet.vim@a3c6182 breaks down snippet expansion keybindings. With init.vim from #396 (comment) I can't expand selected snippet from pumvisible anymore.

@saks
Copy link

saks commented Jan 29, 2019

The same here, the very last commit broke everything for me either.

@Shougo
Copy link

Shougo commented Jan 29, 2019

Please use the latest version of neosnippet.
I have fixed it.

@arahalevich-move
Copy link

Just verified, everything works with the latest master (Shougo/neosnippet.vim@c9b41fe).
@Shougo, thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants