roxma / nvim-completion-manager

:warning: PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
MIT License
917 stars 49 forks source link

SnipMate won't expand if there are multiple options #131

Closed boardfish closed 7 years ago

boardfish commented 7 years ago

Tried the fix in someone else's issue with UltiSnips (#89), but it's not working. When I press the enter key, a newline is created rather than expanding the snippet selected. Tested in Ruby with the def method.

roxma commented 7 years ago

I'll need the minimal vimrc, and steps to reproduce this issue.

boardfish commented 7 years ago

Steps

nvim test.rb idef<TAB>

Result

Many other potential snippets appear, such as 'deft'. You can tab through them but pressing ENTER results in a newline (with the right indent for a def block, strangely).


if has('nvim')
    let s:editor_root=expand("~/.config/nvim")
else
    let s:editor_root=expand("~/.vim")
endif
let mapleader="\<SPACE>"
let g:python_host_prog = '/home/si/.pyenv/versions/general/bin/python'
let g:python3_host_prog = '/home/si/.pyenv/versions/neovim3/bin/python'
set shell=/bin/bash

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" set the backup directory so we don't get weird tilde files...
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'garbas/vim-snipmate'
imap <expr> <CR>  (pumvisible() ?  "\<c-y>\<Plug>(cm_inject_snippet)\<Plug>(expand_or_nl)" : "\<CR>")
imap <expr> <Plug>(expand_or_nl) (has_key(v:completed_item,'snippet')?"\<C-U>":"\<CR>")
Plugin 'roxma/nvim-completion-manager'
" Optional:
Plugin 'honza/vim-snippets'
"Fix for not appearing until i create a new split
set laststatus=2

" All of your Plugins must be added before the following line
call vundle#end()            " required
syntax on
filetype plugin indent on    " required
``
roxma commented 7 years ago

(:help SnipMate) SnipMate depends on vim-addon-mw-utils and tlib.

I can't find it in your vimrc.

boardfish commented 7 years ago

Oh, must've overlooked including it in the trimmed .vimrc. It's definitely in my init.vim.

roxma commented 7 years ago

It is fixed. Use this version instead. The previous version may work, but it is deprecated.

Suppose you use the <c-u> key for expanding snippet:

imap <expr> <CR>  (pumvisible() ?  "\<c-y>\<Plug>(expand_or_nl)" : "\<CR>")
imap <expr> <Plug>(expand_or_nl) (cm#completed_is_snippet() ? "\<C-U>":"\<CR>")
boardfish commented 7 years ago

E117: Unknown function: cm#completed_is_snippet There's another error after that. Zero record of the function existing in the plugin after I grepped the whole directory with `grep -rnw '/home/si/.vim/bundle/nvim-completion-manager/' -e 'cm#snippet' and 'cm#complete' and 'cm#completed_is_snippet'.

roxma commented 7 years ago

have you pull the newest version?

boardfish commented 7 years ago

I did just now. It no longer errors, but deletes what was written beforehand entirely. Same test circumstances, idef<Tab><Enter> results in the word 'def' that was previously written being deleted.

I think your second ternary might be the wrong way round, I'll test it to see. Nope, looks like the problem lies in that <c-u>. How do I map it to expand a snippet?

roxma commented 7 years ago

Something like imap <c-u> <Plug>snipMateTrigger

You need to read the snipMate doc.