- Improved completion behavior.
This commit is contained in:
parent
b475e05455
commit
59f7c05fb2
@ -1,7 +1,7 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
" FILE: snippets_complete.vim
|
" FILE: snippets_complete.vim
|
||||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||||
" Last Modified: 02 Nov 2012.
|
" Last Modified: 04 Nov 2012.
|
||||||
" License: MIT license {{{
|
" License: MIT license {{{
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining
|
" Permission is hereby granted, free of charge, to any person obtaining
|
||||||
" a copy of this software and associated documentation files (the
|
" 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',
|
let abbr_pattern = printf('%%.%ds..%%s',
|
||||||
\ g:neocomplcache_max_keyword_width-10)
|
\ g:neocomplcache_max_keyword_width-10)
|
||||||
for snippet in list
|
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.dup = 1
|
||||||
let snippet.neocomplcache__convertable = 0
|
let snippet.neocomplcache__convertable = 0
|
||||||
let snippet.neocomplcache__refresh = 1
|
|
||||||
|
let snippet.kind = get(snippet,
|
||||||
|
\ 'neocomplcache__refresh', 0) ? '~' : ''
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return list
|
return list
|
||||||
@ -82,15 +73,25 @@ function! s:keyword_filter(snippets, cur_keyword_str)"{{{
|
|||||||
" Uniq by real_name.
|
" Uniq by real_name.
|
||||||
let dict = {}
|
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*$'
|
if len(a:cur_keyword_str) > 1 && a:cur_keyword_str =~ '^\h\w*$'
|
||||||
" Use partial match by filter_str.
|
" Use partial match by filter_str.
|
||||||
let list = filter(values(a:snippets),
|
let partial_list = filter(values(a:snippets),
|
||||||
\ printf('stridx(v:val.filter_str, %s) >= 0',
|
\ printf('stridx(v:val.filter_str, %s) > 0',
|
||||||
\ string(a:cur_keyword_str)))
|
\ string(a:cur_keyword_str)))
|
||||||
else
|
for snippet in partial_list
|
||||||
" Use default filter.
|
" Set refresh flag.
|
||||||
let list = neocomplcache#keyword_filter(
|
let snippet.neocomplcache__refresh = 1
|
||||||
\ values(a:snippets), a:cur_keyword_str)
|
endfor
|
||||||
|
|
||||||
|
let list += partial_list
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Add cur_keyword_str snippet.
|
" Add cur_keyword_str snippet.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
" FILE: neosnippet.vim
|
" FILE: neosnippet.vim
|
||||||
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
|
||||||
" Last Modified: 03 Nov 2012.
|
" Last Modified: 04 Nov 2012.
|
||||||
" License: MIT license {{{
|
" License: MIT license {{{
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining
|
" Permission is hereby granted, free of charge, to any person obtaining
|
||||||
" a copy of this software and associated documentation files (the
|
" 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}'
|
let a:dict.word .= '${0}'
|
||||||
endif
|
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()
|
||||||
\ . '.*' . s:get_placeholder_marker_substitute_pattern()) ?
|
\ . '.*' . s:get_placeholder_marker_substitute_pattern()
|
||||||
\ '<Snip> ' : '[Snip] '
|
let menu_prefix = '<Snip> '
|
||||||
|
else
|
||||||
|
let menu_prefix = '[Snip] '
|
||||||
|
endif
|
||||||
|
|
||||||
if !has_key(a:dict, 'abbr') || a:dict.abbr == ''
|
if !has_key(a:dict, 'abbr') || a:dict.abbr == ''
|
||||||
" Set default 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,
|
\ 'word' : a:dict.name, 'snip' : a:dict.word,
|
||||||
\ 'filter_str' : a:dict.name . ' ' . a:dict.abbr,
|
\ 'filter_str' : a:dict.name . ' ' . a:dict.abbr,
|
||||||
\ 'description' : a:dict.word,
|
\ 'description' : a:dict.word,
|
||||||
\ 'menu' : menu_pattern . abbr,
|
\ 'menu' : menu_prefix . abbr,
|
||||||
\ 'options' : a:dict.options,
|
\ 'options' : a:dict.options,
|
||||||
\ 'action__path' : a:path, 'action__line' : a:line,
|
\ 'action__path' : a:path, 'action__line' : a:line,
|
||||||
\ 'action__pattern' : a:pattern, 'real_name' : a:name,
|
\ 'action__pattern' : a:pattern, 'real_name' : a:name,
|
||||||
|
@ -683,6 +683,9 @@ A: Please try below settings. It defines snipMate function.
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
CHANGELOG *neosnippet-changelog*
|
CHANGELOG *neosnippet-changelog*
|
||||||
|
|
||||||
|
2012-11-04
|
||||||
|
- Improved completion behavior.
|
||||||
|
|
||||||
2012-11-03
|
2012-11-03
|
||||||
- Refactored documentation.
|
- Refactored documentation.
|
||||||
- Added :NeoSnippetSource.
|
- Added :NeoSnippetSource.
|
||||||
|
Loading…
Reference in New Issue
Block a user