- Delete simple markers when InsertLeave.

This commit is contained in:
Shougo Matsushita 2013-02-16 20:50:22 +09:00
parent 6b10975d74
commit 925c03824d
2 changed files with 39 additions and 1 deletions

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: neosnippet.vim " FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 20 Jan 2013. " Last Modified: 16 Feb 2013.
" License: MIT license {{{ " License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining " Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the " a copy of this software and associated documentation files (the
@ -1238,6 +1238,40 @@ function! s:skip_next_auto_completion() "{{{
endif endif
endfunction"}}} endfunction"}}}
function! s:on_insert_leave() "{{{
" Get patterns and count.
if empty(s:snippets_expand_stack)
return
endif
let expand_info = s:snippets_expand_stack[-1]
" Search patterns.
let [begin, end] = s:get_snippet_range(
\ expand_info.begin_line,
\ expand_info.begin_patterns,
\ expand_info.end_line,
\ expand_info.end_patterns)
if begin != end
return
endif
let pos = getpos('.')
try
while s:search_snippet_range(begin, end, expand_info.holder_cnt)
" Next count.
let expand_info.holder_cnt += 1
endwhile
" Search placeholder 0.
call s:search_snippet_range(begin, end, 0)
finally
stopinsert
call setpos('.', pos)
endtry
endfunction"}}}
if g:neosnippet#enable_snipmate_compatibility if g:neosnippet#enable_snipmate_compatibility
" For snipMate function. " For snipMate function.
function! Filename(...) function! Filename(...)
@ -1312,6 +1346,7 @@ function! s:initialize_others() "{{{
\ call neosnippet#recaching() \ call neosnippet#recaching()
autocmd BufEnter * autocmd BufEnter *
\ call neosnippet#clear_select_mode_mappings() \ call neosnippet#clear_select_mode_mappings()
autocmd InsertLeave * call s:on_insert_leave()
augroup END"}}} augroup END"}}}
augroup neosnippet augroup neosnippet

View File

@ -656,6 +656,8 @@ line in snippet end, you must insert placeholder.
< <
Note: If you expand oneline snippet, the markers will be deleted in
|InsertLeave|.
============================================================================== ==============================================================================
UNITE SOURCES *neosnippet-unite-sources* UNITE SOURCES *neosnippet-unite-sources*
@ -721,6 +723,7 @@ CHANGELOG *neosnippet-changelog*
2013-02-16 2013-02-16
- Added sh snippet. - Added sh snippet.
- Added html snippet. - Added html snippet.
- Delete simple markers when InsertLeave.
2013-02-03 2013-02-03
- Improved php snippets. - Improved php snippets.