Skip to content

Commit

Permalink
Implement restore unnamed register feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jan 26, 2016
1 parent 52f8a29 commit a323d82
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions autoload/neosnippet/handlers.vim
Expand Up @@ -74,6 +74,16 @@ function! neosnippet#handlers#_all_clear_markers() "{{{
endtry
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 "{{{
return get(g:, 'neopairs#enable', 0)
endfunction"}}}
Expand Down
2 changes: 2 additions & 0 deletions autoload/neosnippet/init.vim
Expand Up @@ -57,6 +57,8 @@ function! s:initialize_others() "{{{
\ call neosnippet#variables#set_snippets({})
autocmd BufEnter *
\ call neosnippet#mappings#_clear_select_mode_mappings()
autocmd TextChanged,TextChangedI *
\ call neosnippet#handlers#_restore_unnamed_register()
augroup END"}}}

if g:neosnippet#enable_auto_clear_markers
Expand Down
1 change: 1 addition & 0 deletions autoload/neosnippet/variables.vim
Expand Up @@ -34,6 +34,7 @@ function! neosnippet#variables#current_neosnippet() "{{{
\ 'target' : '',
\ 'trigger' : 0,
\ 'optional_tabstop' : 0,
\ 'unnamed_register' : '',
\}
endif

Expand Down
2 changes: 2 additions & 0 deletions autoload/neosnippet/view.vim
Expand Up @@ -408,6 +408,8 @@ function! s:expand_placeholder(start, end, holder_cnt, line, ...) "{{{

if default_len > 0 && is_select
" Select default value.
let neosnippet.unnamed_register = @"

let len = default_len-1
if &l:selection == 'exclusive'
let len += 1
Expand Down

0 comments on commit a323d82

Please sign in to comment.