Add g:neosnippet#enable_auto_clear_markers option
This commit is contained in:
parent
de5a7e284d
commit
12ebafeb81
@ -43,6 +43,8 @@ call neosnippet#util#set_default(
|
|||||||
\ 'g:neosnippet#enable_conceal_markers', 1)
|
\ 'g:neosnippet#enable_conceal_markers', 1)
|
||||||
call neosnippet#util#set_default(
|
call neosnippet#util#set_default(
|
||||||
\ 'g:neosnippet#enable_complete_done', 0)
|
\ 'g:neosnippet#enable_complete_done', 0)
|
||||||
|
call neosnippet#util#set_default(
|
||||||
|
\ 'g:neosnippet#enable_auto_clear_markers', 1)
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
function! neosnippet#expandable_or_jumpable() "{{{
|
function! neosnippet#expandable_or_jumpable() "{{{
|
||||||
|
@ -142,42 +142,7 @@ function! neosnippet#commands#_clear_markers() "{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let expand_info = expand_stack[-1]
|
call neosnippet#view#_clear_markers(expand_info[-1])
|
||||||
|
|
||||||
" Search patterns.
|
|
||||||
let [begin, end] = neosnippet#view#_get_snippet_range(
|
|
||||||
\ expand_info.begin_line,
|
|
||||||
\ expand_info.begin_patterns,
|
|
||||||
\ expand_info.end_line,
|
|
||||||
\ expand_info.end_patterns)
|
|
||||||
|
|
||||||
let mode = mode()
|
|
||||||
let pos = getpos('.')
|
|
||||||
|
|
||||||
" Found snippet.
|
|
||||||
let found = 0
|
|
||||||
try
|
|
||||||
while neosnippet#view#_search_snippet_range(
|
|
||||||
\ begin, end, expand_info.holder_cnt, 0)
|
|
||||||
|
|
||||||
" Next count.
|
|
||||||
let expand_info.holder_cnt += 1
|
|
||||||
let found = 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
" Search placeholder 0.
|
|
||||||
if neosnippet#view#_search_snippet_range(begin, end, 0)
|
|
||||||
let found = 1
|
|
||||||
endif
|
|
||||||
finally
|
|
||||||
if found && mode !=# 'i'
|
|
||||||
stopinsert
|
|
||||||
endif
|
|
||||||
|
|
||||||
call setpos('.', pos)
|
|
||||||
|
|
||||||
call neosnippet#variables#clear_expand_stack()
|
|
||||||
endtry
|
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
" Complete helpers.
|
" Complete helpers.
|
||||||
|
@ -97,7 +97,7 @@ function! neosnippet#handlers#_cursor_moved() "{{{
|
|||||||
let expand_info = expand_stack[-1]
|
let expand_info = expand_stack[-1]
|
||||||
if expand_info.begin_line == expand_info.end_line
|
if expand_info.begin_line == expand_info.end_line
|
||||||
\ && line('.') != expand_info.begin_line
|
\ && line('.') != expand_info.begin_line
|
||||||
call neosnippet#commands#_clear_markers()
|
call neosnippet#view#_clear_markers(expand_info)
|
||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
@ -105,15 +105,14 @@ function! neosnippet#handlers#_all_clear_markers() "{{{
|
|||||||
let pos = getpos('.')
|
let pos = getpos('.')
|
||||||
|
|
||||||
try
|
try
|
||||||
" Search out of range.
|
while !empty(neosnippet#variables#expand_stack())
|
||||||
while neosnippet#view#_search_outof_range(col('.'))
|
call neosnippet#view#_clear_markers(
|
||||||
|
\ neosnippet#variables#expand_stack()[-1])
|
||||||
endwhile
|
endwhile
|
||||||
finally
|
finally
|
||||||
stopinsert
|
stopinsert
|
||||||
|
|
||||||
call setpos('.', pos)
|
call setpos('.', pos)
|
||||||
|
|
||||||
call neosnippet#variables#clear_expand_stack()
|
|
||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
@ -57,12 +57,15 @@ function! s:initialize_others() "{{{
|
|||||||
\ call neosnippet#variables#set_snippets({})
|
\ call neosnippet#variables#set_snippets({})
|
||||||
autocmd BufEnter *
|
autocmd BufEnter *
|
||||||
\ call neosnippet#mappings#_clear_select_mode_mappings()
|
\ call neosnippet#mappings#_clear_select_mode_mappings()
|
||||||
autocmd CursorMoved,CursorMovedI *
|
|
||||||
\ call neosnippet#handlers#_cursor_moved()
|
|
||||||
autocmd BufWritePre *
|
|
||||||
\ call neosnippet#handlers#_all_clear_markers()
|
|
||||||
augroup END"}}}
|
augroup END"}}}
|
||||||
|
|
||||||
|
if g:neosnippet#enable_auto_clear_markers
|
||||||
|
autocmd neosnippet CursorMoved,CursorMovedI *
|
||||||
|
\ call neosnippet#handlers#_cursor_moved()
|
||||||
|
autocmd neosnippet BufWritePre *
|
||||||
|
\ call neosnippet#handlers#_all_clear_markers()
|
||||||
|
endif
|
||||||
|
|
||||||
if exists('v:completed_item')
|
if exists('v:completed_item')
|
||||||
autocmd neosnippet CompleteDone *
|
autocmd neosnippet CompleteDone *
|
||||||
\ call neosnippet#handlers#_complete_done()
|
\ call neosnippet#handlers#_complete_done()
|
||||||
|
@ -297,6 +297,42 @@ function! neosnippet#view#_search_outof_range(col) "{{{
|
|||||||
" Not found.
|
" Not found.
|
||||||
return 0
|
return 0
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
function! neosnippet#view#_clear_markers(expand_info) "{{{
|
||||||
|
" Search patterns.
|
||||||
|
let [begin, end] = neosnippet#view#_get_snippet_range(
|
||||||
|
\ a:expand_info.begin_line,
|
||||||
|
\ a:expand_info.begin_patterns,
|
||||||
|
\ a:expand_info.end_line,
|
||||||
|
\ a:expand_info.end_patterns)
|
||||||
|
|
||||||
|
let mode = mode()
|
||||||
|
let pos = getpos('.')
|
||||||
|
|
||||||
|
" Found snippet.
|
||||||
|
let found = 0
|
||||||
|
try
|
||||||
|
while neosnippet#view#_search_snippet_range(
|
||||||
|
\ begin, end, a:expand_info.holder_cnt, 0)
|
||||||
|
|
||||||
|
" Next count.
|
||||||
|
let a:expand_info.holder_cnt += 1
|
||||||
|
let found = 1
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
" Search placeholder 0.
|
||||||
|
if neosnippet#view#_search_snippet_range(begin, end, 0)
|
||||||
|
let found = 1
|
||||||
|
endif
|
||||||
|
finally
|
||||||
|
if found && mode !=# 'i'
|
||||||
|
stopinsert
|
||||||
|
endif
|
||||||
|
|
||||||
|
call setpos('.', pos)
|
||||||
|
|
||||||
|
call neosnippet#variables#pop_expand_stack()
|
||||||
|
endtry
|
||||||
|
endfunction"}}}
|
||||||
function! s:expand_placeholder(start, end, holder_cnt, line, ...) "{{{
|
function! s:expand_placeholder(start, end, holder_cnt, line, ...) "{{{
|
||||||
let is_select = get(a:000, 0, 1)
|
let is_select = get(a:000, 0, 1)
|
||||||
|
|
||||||
|
@ -232,6 +232,14 @@ g:neosnippet#enable_complete_done
|
|||||||
|
|
||||||
The default value is 0.
|
The default value is 0.
|
||||||
|
|
||||||
|
*g:neosnippet#enable_auto_clear_markers*
|
||||||
|
g:neosnippet#enable_auto_clear_markers
|
||||||
|
If this variable is not 0, neosnippet will clear the markers
|
||||||
|
in the buffer when |BufWritePost|, |CursorMoved| and
|
||||||
|
|CursorMovedI| autocmd.
|
||||||
|
|
||||||
|
The default value is 1.
|
||||||
|
|
||||||
*g:neosnippet#scope_aliases*
|
*g:neosnippet#scope_aliases*
|
||||||
g:neosnippet#scope_aliases
|
g:neosnippet#scope_aliases
|
||||||
It is a dictionary that associating certain filetypes with
|
It is a dictionary that associating certain filetypes with
|
||||||
|
Loading…
Reference in New Issue
Block a user