Implement restore unnamed register feature

This commit is contained in:
Shougo Matsushita 2016-01-26 21:32:31 +09:00
parent 52f8a29489
commit a323d8255a
4 changed files with 15 additions and 0 deletions

View File

@ -74,6 +74,16 @@ function! neosnippet#handlers#_all_clear_markers() "{{{
endtry endtry
endfunction"}}} endfunction"}}}
function! neosnippet#handlers#_restore_unnamed_register() "{{{
let neosnippet = neosnippet#variables#current_neosnippet()
if neosnippet.unnamed_register != ''
\ && @" !=# neosnippet.unnamed_register
let @" = neosnippet.unnamed_register
let neosnippet.unnamed_register = ''
endif
endfunction"}}}
function! s:is_auto_pairs() abort "{{{ function! s:is_auto_pairs() abort "{{{
return get(g:, 'neopairs#enable', 0) return get(g:, 'neopairs#enable', 0)
endfunction"}}} endfunction"}}}

View File

@ -57,6 +57,8 @@ 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 TextChanged,TextChangedI *
\ call neosnippet#handlers#_restore_unnamed_register()
augroup END"}}} augroup END"}}}
if g:neosnippet#enable_auto_clear_markers if g:neosnippet#enable_auto_clear_markers

View File

@ -34,6 +34,7 @@ function! neosnippet#variables#current_neosnippet() "{{{
\ 'target' : '', \ 'target' : '',
\ 'trigger' : 0, \ 'trigger' : 0,
\ 'optional_tabstop' : 0, \ 'optional_tabstop' : 0,
\ 'unnamed_register' : '',
\} \}
endif endif

View File

@ -408,6 +408,8 @@ function! s:expand_placeholder(start, end, holder_cnt, line, ...) "{{{
if default_len > 0 && is_select if default_len > 0 && is_select
" Select default value. " Select default value.
let neosnippet.unnamed_register = @"
let len = default_len-1 let len = default_len-1
if &l:selection == 'exclusive' if &l:selection == 'exclusive'
let len += 1 let len += 1