Fix completed snippet feature

This commit is contained in:
Shougo Matsushita 2015-12-12 01:51:49 +09:00
parent 3814544033
commit 7dc7ce803e
2 changed files with 16 additions and 9 deletions

View File

@ -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 options = neosnippet#parser#_initialize_snippet_options()
let options.word = 1
@ -124,15 +126,16 @@ function! neosnippet#handlers#_get_in_paren(str) abort "{{{
endif
endif
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

View File

@ -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