- Improved completion behavior.

This commit is contained in:
Shougo Matsushita 2012-11-04 20:47:54 +09:00
parent b475e05455
commit 59f7c05fb2
3 changed files with 33 additions and 24 deletions

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: snippets_complete.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" 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 =~ '\\\@<!`=.*\\\@<!`'
let snippet.menu = s:eval_snippet(snippet.snip)
if g:neocomplcache_max_keyword_width >= 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.

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: neosnippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" 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 =~ '\\\@<!`.*\\\@<!`'
let menu_prefix = '`Snip` '
elseif a:dict.word =~
\ s:get_placeholder_marker_substitute_pattern()
\ . '.*' . s:get_placeholder_marker_substitute_pattern()) ?
\ '<Snip> ' : '[Snip] '
\ . '.*' . s:get_placeholder_marker_substitute_pattern()
let menu_prefix = '<Snip> '
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,

View File

@ -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.