From befa939da65528f59b33d9d054c2f07c8f285877 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Thu, 18 Oct 2012 12:28:51 +0900 Subject: [PATCH] - Added unite__new_candidate action in snippet source. --- autoload/unite/sources/snippet.vim | 24 ++++++++++++++++++++++++ doc/neosnippet.txt | 1 + 2 files changed, 25 insertions(+) diff --git a/autoload/unite/sources/snippet.vim b/autoload/unite/sources/snippet.vim index edd5759..b716369 100644 --- a/autoload/unite/sources/snippet.vim +++ b/autoload/unite/sources/snippet.vim @@ -114,6 +114,30 @@ function! s:action_table.preview.func(candidates)"{{{ endfor endfunction"}}} +let s:action_table.unite__new_candidate = { + \ 'description' : 'add new snippet', + \ 'is_quit' : 1, + \ } +function! s:action_table.unite__new_candidate.func(candidate)"{{{ + call unite#take_action('open', a:candidate) + if &filetype != 'snippet' + " Open failed. + return + endif + + if getline('$') != '' + " Append line. + call append('$', '') + endif + + call append('$', ['snippet ', 'abbr ', + \ "prev_word '^'", ' ']) + + call cursor(line('$') - 3, 0) + call cursor(0, col('$')) +endfunction"}}} + + let s:source.action_table = s:action_table unlet! s:action_table "}}} diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index 0f71e53..e113e07 100644 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -419,6 +419,7 @@ CHANGELOG *neosnippet-changelog* - Fixed alias problem. - Improved escape placeholder. - Fixed s:get_sources_list(). +- Added unite__new_candidate action in snippet source. 2012-10-15 - Improved lua snip.