Add arguments_are_optional completion setting
This commit is contained in:
parent
382f68dbd0
commit
e416d25436
@ -22,6 +22,8 @@ call neosnippet#util#set_default(
|
|||||||
call neosnippet#util#set_default(
|
call neosnippet#util#set_default(
|
||||||
\ 'g:neosnippet#enable_completed_snippet', 0,
|
\ 'g:neosnippet#enable_completed_snippet', 0,
|
||||||
\ 'g:neosnippet#enable_complete_done')
|
\ 'g:neosnippet#enable_complete_done')
|
||||||
|
call neosnippet#util#set_default(
|
||||||
|
\ 'g:neosnippet#arguments_are_optional', 1)
|
||||||
call neosnippet#util#set_default(
|
call neosnippet#util#set_default(
|
||||||
\ 'g:neosnippet#enable_auto_clear_markers', 1)
|
\ 'g:neosnippet#enable_auto_clear_markers', 1)
|
||||||
call neosnippet#util#set_default(
|
call neosnippet#util#set_default(
|
||||||
|
@ -339,9 +339,7 @@ function! neosnippet#parser#_get_completed_snippet(completed_item, cur_text, nex
|
|||||||
for arg in split(substitute(
|
for arg in split(substitute(
|
||||||
\ neosnippet#parser#_get_in_paren('<', '>', abbr),
|
\ neosnippet#parser#_get_in_paren('<', '>', abbr),
|
||||||
\ '<\zs.\{-}\ze>', '', 'g'), '[^[]\zs\s*,\s*')
|
\ '<\zs.\{-}\ze>', '', 'g'), '[^[]\zs\s*,\s*')
|
||||||
let args .= printf('${%d:#:%s%s}',
|
let args .= neosnippet#parser#_conceal_argument(arg, cnt, args)
|
||||||
\ cnt, ((args != '') ? ', ' : ''),
|
|
||||||
\ escape(arg, '{}'))
|
|
||||||
let cnt += 1
|
let cnt += 1
|
||||||
endfor
|
endfor
|
||||||
let snippet .= args
|
let snippet .= args
|
||||||
@ -362,9 +360,7 @@ function! neosnippet#parser#_get_completed_snippet(completed_item, cur_text, nex
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let args .= printf('${%d:#:%s%s}',
|
let args .= neosnippet#parser#_conceal_argument(arg, cnt, args)
|
||||||
\ cnt, ((args != '') ? ', ' : ''),
|
|
||||||
\ escape(arg, '{}'))
|
|
||||||
let cnt += 1
|
let cnt += 1
|
||||||
endfor
|
endfor
|
||||||
let snippet .= args
|
let snippet .= args
|
||||||
@ -406,4 +402,16 @@ function! neosnippet#parser#_get_in_paren(key, pair, str) abort "{{{
|
|||||||
return ''
|
return ''
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
function! neosnippet#parser#_conceal_argument(arg, cnt, args) abort "{{{
|
||||||
|
let outside = ''
|
||||||
|
let inside = ''
|
||||||
|
if (a:args != '')
|
||||||
|
if g:neosnippet#arguments_are_optional
|
||||||
|
let inside = ', '
|
||||||
|
else
|
||||||
|
let outside = ', '
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return printf('%s${%d:#:%s%s}', outside, a:cnt, inside, escape(a:arg, '{}'))
|
||||||
|
endfunction"}}}
|
||||||
" vim: foldmethod=marker
|
" vim: foldmethod=marker
|
||||||
|
Loading…
Reference in New Issue
Block a user