Improve snippet source

This commit is contained in:
Shougo Matsushita 2013-12-31 07:37:27 +09:00
parent 4fc33adfd5
commit 3a2e43a934
1 changed files with 14 additions and 21 deletions

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: snippet.vim " FILE: snippet.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> " AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 21 Nov 2013. " Last Modified: 31 Dec 2013.
" 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
@ -55,26 +55,19 @@ function! s:source.hooks.on_init(args, context) "{{{
endfunction"}}} endfunction"}}}
function! s:source.gather_candidates(args, context) "{{{ function! s:source.gather_candidates(args, context) "{{{
let keyword_pos = a:context.source__cur_keyword_pos return map(copy(a:context.source__snippets), "{
let list = [] \ 'word' : v:val.word,
for keyword in a:context.source__snippets \ 'abbr' : printf('%-50s %s', v:val.word, v:val.menu_abbr),
let dict = { \ 'kind' : 'snippet',
\ 'word' : keyword.word, \ 'dup' : 1,
\ 'abbr' : printf('%-50s %s', keyword.word, keyword.menu_abbr), \ 'action__complete_word' : v:val.word,
\ 'kind': 'snippet', \ 'action__complete_pos' : a:context.source__cur_keyword_pos,
\ 'action__complete_word' : keyword.word, \ 'action__path' : v:val.action__path,
\ 'action__complete_pos' : keyword_pos, \ 'action__pattern' : v:val.action__pattern,
\ 'action__path' : keyword.action__path, \ 'source__menu' : v:val.menu_abbr,
\ 'action__pattern' : keyword.action__pattern, \ 'source__snip' : v:val.snip,
\ 'source__menu' : keyword.menu_abbr, \ 'source__snip_ref' : v:val,
\ 'source__snip' : keyword.snip, \ "})
\ 'source__snip_ref' : keyword,
\ }
call add(list, dict)
endfor
return list
endfunction "}}} endfunction "}}}
" Actions "{{{ " Actions "{{{