From 7dc7ce803e28783bcbb829bfdbe8bbae6e51139a Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sat, 12 Dec 2015 01:51:49 +0900 Subject: [PATCH] Fix completed snippet feature --- autoload/neosnippet/handlers.vim | 21 ++++++++++++--------- test/functions.vim | 4 ++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/autoload/neosnippet/handlers.vim b/autoload/neosnippet/handlers.vim index 67c18b5..d108da0 100644 --- a/autoload/neosnippet/handlers.vim +++ b/autoload/neosnippet/handlers.vim @@ -50,7 +50,7 @@ function! neosnippet#handlers#_complete_done() "{{{ let abbr = split(item.info, '\n')[0] endif - if abbr !~ '(.*)' + if abbr !~ '(' return endif @@ -69,14 +69,16 @@ function! neosnippet#handlers#_complete_done() "{{{ let snippet .= printf('${%d:#:%s}', cnt, escape(arg, '{}')) let cnt += 1 endfor - if snippet !~ ')$' - let snippet .= ')' - endif + if s:is_auto_pairs() " Remove auto pair from the snippet let snippet = substitute(snippet, ')$', '', '') + else + if snippet !~ ')$' + let snippet .= ')' + endif + let snippet .= '${0}' endif - let snippet .= '${0}' let options = neosnippet#parser#_initialize_snippet_options() let options.word = 1 @@ -124,15 +126,16 @@ function! neosnippet#handlers#_get_in_paren(str) abort "{{{ endif endif - let s .= c + if level > 0 + let s .= c + endif endfor - return s + return '' endfunction"}}} function! s:is_auto_pairs() abort "{{{ - return get(g:, 'deoplete#enable_auto_pairs', 0) - \ || get(g:, 'neocomplete#enable_auto_pairs', 0) + return get(g:, 'neopairs#enable', 0) endfunction"}}} let &cpo = s:save_cpo diff --git a/test/functions.vim b/test/functions.vim index f493c4b..9ebf8b8 100644 --- a/test/functions.vim +++ b/test/functions.vim @@ -8,5 +8,9 @@ function! s:suite.get_in_paren() \ 'foobar, baz') call s:assert.equals(neosnippet#handlers#_get_in_paren('(foobar, (baz))'), \ 'foobar, (baz)') + call s:assert.equals(neosnippet#handlers#_get_in_paren('foobar('), + \ '') + call s:assert.equals(neosnippet#handlers#_get_in_paren('foobar(fname)'), + \ 'fname') endfunction