diff --git a/autoload/neocomplcache/sources/snippets_complete.vim b/autoload/neocomplcache/sources/snippets_complete.vim index fe01916..731cc2e 100644 --- a/autoload/neocomplcache/sources/snippets_complete.vim +++ b/autoload/neocomplcache/sources/snippets_complete.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: snippets_complete.vim " AUTHOR: Shougo Matsushita -" Last Modified: 02 Nov 2012. +" Last Modified: 04 Nov 2012. " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the @@ -59,20 +59,11 @@ function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str)"{{{ let abbr_pattern = printf('%%.%ds..%%s', \ g:neocomplcache_max_keyword_width-10) for snippet in list - if snippet.snip =~ '\\\@= 0 && - \ len(snippet.menu) > g:neocomplcache_max_keyword_width - let snippet.menu = printf(abbr_pattern, - \ snippet.menu, snippet.menu[-8:]) - endif - let snippet.menu = '`Snip` ' . snippet.menu - endif - let snippet.dup = 1 let snippet.neocomplcache__convertable = 0 - let snippet.neocomplcache__refresh = 1 + + let snippet.kind = get(snippet, + \ 'neocomplcache__refresh', 0) ? '~' : '' endfor return list @@ -82,15 +73,25 @@ function! s:keyword_filter(snippets, cur_keyword_str)"{{{ " Uniq by real_name. let dict = {} + " Use default filter. + let list = neocomplcache#keyword_filter( + \ values(a:snippets), a:cur_keyword_str) + for snippet in list + " reset refresh flag. + let snippet.neocomplcache__refresh = 0 + endfor + if len(a:cur_keyword_str) > 1 && a:cur_keyword_str =~ '^\h\w*$' " Use partial match by filter_str. - let list = filter(values(a:snippets), - \ printf('stridx(v:val.filter_str, %s) >= 0', + let partial_list = filter(values(a:snippets), + \ printf('stridx(v:val.filter_str, %s) > 0', \ string(a:cur_keyword_str))) - else - " Use default filter. - let list = neocomplcache#keyword_filter( - \ values(a:snippets), a:cur_keyword_str) + for snippet in partial_list + " Set refresh flag. + let snippet.neocomplcache__refresh = 1 + endfor + + let list += partial_list endif " Add cur_keyword_str snippet. diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index c630cd3..a20de4e 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: neosnippet.vim " AUTHOR: Shougo Matsushita -" Last Modified: 03 Nov 2012. +" Last Modified: 04 Nov 2012. " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the @@ -196,10 +196,15 @@ function! s:initialize_snippet(dict, path, line, pattern, name)"{{{ let a:dict.word .= '${0}' endif - let menu_pattern = (a:dict.word =~ + if a:dict.word =~ '\\\@ ' : '[Snip] ' + \ . '.*' . s:get_placeholder_marker_substitute_pattern() + let menu_prefix = ' ' + else + let menu_prefix = '[Snip] ' + endif if !has_key(a:dict, 'abbr') || a:dict.abbr == '' " Set default abbr. @@ -216,7 +221,7 @@ function! s:initialize_snippet(dict, path, line, pattern, name)"{{{ \ 'word' : a:dict.name, 'snip' : a:dict.word, \ 'filter_str' : a:dict.name . ' ' . a:dict.abbr, \ 'description' : a:dict.word, - \ 'menu' : menu_pattern . abbr, + \ 'menu' : menu_prefix . abbr, \ 'options' : a:dict.options, \ 'action__path' : a:path, 'action__line' : a:line, \ 'action__pattern' : a:pattern, 'real_name' : a:name, diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index c21fa65..41f7ac7 100644 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -683,6 +683,9 @@ A: Please try below settings. It defines snipMate function. ============================================================================== CHANGELOG *neosnippet-changelog* +2012-11-04 +- Improved completion behavior. + 2012-11-03 - Refactored documentation. - Added :NeoSnippetSource.