Shougo / neosnippet.vim

neo-snippet plugin
Other
1.12k stars 108 forks source link

Expand from deoplete bug #489

Closed mac-hel closed 4 years ago

mac-hel commented 4 years ago

Plugin expands wrong snippet for multi-word snippet names when snippet is selected from deoplete list Tested for JS and PHP

Steps to repr: insert 'if' in insert mode, select "if-else" from deoplete list, hit "< C-K >" Current behav: snippet is expanded for "if" (without else) Expected beh: should be expanded for "if-else"

I think neosnippet is fetching 'if" from buffer text instead of 'if-else' from deoplete list

related .vimrc:

Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'

call deoplete#custom#option('sources', {
    \ 'javascript': ['around', 'member', 'buffer', 'file', 'neosnippet', 'tern', 'flow'],
\ })
imap <C-k>     <Plug>(neosnippet_expand_or_jump)
smap <C-k>     <Plug>(neosnippet_expand_or_jump)
xmap <C-k>     <Plug>(neosnippet_expand_target)
imap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
Shougo commented 4 years ago

I don't reproduce the problem. Closing.

I have tested it on javascript files. Please upload the reproduce-able instructions for me.

set rtp+=~/work/deoplete.nvim/
set rtp+=~/work/neosnippet.vim
set rtp+=~/work/neosnippet-snippets
let g:deoplete#enable_at_startup = 1

call deoplete#custom#option('sources', {
    \ 'javascript': ['around', 'member', 'buffer', 'file', 'neosnippet', 'tern', 'flow'],
\ })
imap <C-k>     <Plug>(neosnippet_expand_or_jump)
smap <C-k>     <Plug>(neosnippet_expand_or_jump)
xmap <C-k>     <Plug>(neosnippet_expand_target)
imap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
Shougo commented 4 years ago

Reproduce steps.

What's wrong???

mac-hel commented 4 years ago

I was trying switching on/off various deoplete settings and always same result - neosnippet is picking 'if' instead of 'if-else'

Works ok If i hardcode 'if-else' here 'neosnippet.vim/autoload/neosnippet/mappings.vim' like this:

function! neosnippet#mappings#_pre_trigger() abort
  call neosnippet#init#check()

  let cur_text = neosnippet#util#get_cur_text()
  let cur_text = 'if-else'                          " <<< HARDCODED

  let col = col('.')
  let expr = ''
  if mode() !=# 'i'
    " Fix column.
    let col += 2
  endif

  " Get selected text.
  let neosnippet = neosnippet#variables#current_neosnippet()
  let neosnippet.trigger = 1
  if mode() ==# 's' && neosnippet.optional_tabstop
    let expr .= "\<C-o>\"_d"
  endif

  return [cur_text, col, expr]
endfunction

I try to investigate it further

mac-hel commented 4 years ago

I know what problem is (are):

Shougo commented 4 years ago

selecting item on deoplete list with arrow keys (up/down) + C-K does not work. If i select item with C-P/C-N + C-K work as expected

Why don't you explain it for me in the first issue comment?? Have you read my reproduce-able steps??

Steps to repr: insert 'if' in insert mode, select "if-else" from deoplete list, hit "< C-K >" Current behav: snippet is expanded for "if" (without else)

It does not say select "if-else" by arrow keys! It confuses me.

And it is the feature of Vim. If you select by allow keys, it is not inserted. So neosnippet cannot detect the input.

Shougo commented 4 years ago

converter_auto_paren breaks neosnippets

it inserts ( at the word end and neosnippet does not expand this word

It is the feature.

mac-hel commented 4 years ago

Why don't you explain it for me in the first issue comment??

Sorry mate, i did not know there is difference between arrows and c-p/n :)

It is the feature.

Does not look like the feature, may be confusing when you add this converter and snippets stop to work. But now when i know i just removed this converter.

Thanks for great plugin. I use few of your plugins and wanted to be helpful.