From 2da0d192af92473516b82c265cda6d00b9a596fa Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Wed, 7 Mar 2012 10:05:00 +0900 Subject: [PATCH] - Improved snippet source. --- autoload/unite/sources/snippet.vim | 20 +++++++++----------- doc/neocomplcache-snippets-complete.txt | 1 + 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/autoload/unite/sources/snippet.vim b/autoload/unite/sources/snippet.vim index 3429285..41f9032 100644 --- a/autoload/unite/sources/snippet.vim +++ b/autoload/unite/sources/snippet.vim @@ -56,7 +56,8 @@ function! s:source.hooks.on_init(args, context) "{{{ let a:context.source__cur_keyword_pos = \ s:get_keyword_pos(neocomplcache#get_cur_text(1)) let a:context.source__snippets = - \ sort(values(neocomplcache#sources#snippets_complete#get_snippets()), 's:compare_words') + \ sort(values(neocomplcache#sources#snippets_complete#get_snippets()), + \ 's:compare_words') endfunction"}}} function! s:source.gather_candidates(args, context) "{{{ @@ -88,11 +89,13 @@ let s:action_table.expand = { \ 'description' : 'expand snippet', \ } function! s:action_table.expand.func(candidate)"{{{ + let cur_text = neocomplcache#get_cur_text(1) + let [_, cur_keyword_str] = + \ neocomplcache#match_word(cur_text) let context = unite#get_context() call neocomplcache#sources#snippets_complete#expand( - \ neocomplcache#get_cur_text(1) . a:candidate.action__complete_word, - \ context.col, - \ a:candidate.action__complete_word) + \ cur_text . a:candidate.action__complete_word[len(cur_keyword_str)], + \ context.col, a:candidate.action__complete_word) endfunction"}}} let s:action_table.preview = { @@ -117,13 +120,8 @@ unlet! s:action_table "}}} function! unite#sources#snippet#start_complete() "{{{ - let winheight = - \ (&pumheight != 0) ? &pumheight : (winheight(0) - winline()) - - return unite#start_complete(['snippet'], { - \ 'winheight' : winheight, - \ 'auto_resize' : 1, - \ }) + return unite#start_complete(['snippet'], + \ { 'input': neocomplcache#get_cur_text(1) }) endfunction "}}} function! s:compare_words(i1, i2)"{{{ diff --git a/doc/neocomplcache-snippets-complete.txt b/doc/neocomplcache-snippets-complete.txt index e2c2b6a..73832b0 100644 --- a/doc/neocomplcache-snippets-complete.txt +++ b/doc/neocomplcache-snippets-complete.txt @@ -297,6 +297,7 @@ CHANGELOG *neocomplcache-snippets-complete-changelog* 2012-03-07 - Added snippet source. - Fixed snippet source behavior. +- Improved snippet source. 2012-03-06 - Improved ftplugin.