public
Last active — forked from thinca/GetSnippetsList.diff

neocomplcache + snipMate

  • Download Gist
GetSnippetsList.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
*** snipMate.vim.old 2009-04-23 02:30:12.703125000 +0900
--- snipMate.vim 2009-04-23 01:41:56.890625000 +0900
***************
*** 187,190 ****
--- 187,202 ----
let num = inputlist(snippet) - 1
return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1]
endf
+
+ fun GetSnippetsList(ft)
+ let s = {}
+ for i in ['s:snippets["_"]', 's:multi_snips["_"]',
+ \ 's:snippets[a:ft]', 's:multi_snips[a:ft]']
+ if exists(i)
+ let s = extend(s, deepcopy(eval(i)))
+ endif
+ endfor
+ return s
+ endf
+
" vim:noet:sw=4:ts=4:ft=vim
snipMate_complete.vim
VimL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
let s:source = {
\ 'name' : 'snipMate_complete',
\ 'kind' : 'plugin',
\}
 
function! s:source.initialize()
let s:snip_list = {}
endfunction
 
function! s:source.finalize()
endfunction
 
function! s:source.get_keyword_list(cur_keyword_str)
let ft = neocomplcache#get_context_filetype()
 
if has_key(s:snip_list, ft)
return neocomplcache#keyword_filter(copy(s:snip_list[ft]), a:cur_keyword_str)
end
 
let snips = GetSnippetsList(ft)
if empty(snips)
return []
endif
 
let l:abbr_pattern = printf('%%.%ds..%%s', g:neocomplcache_max_keyword_width-10)
let l:menu_pattern = '<S> %.'.g:neocomplcache_max_filename_width.'s'
 
let list = []
for trig in keys(snips)
if type(snips[trig]) == type([])
let s:triger = 'multi snips - ' . snips[trig][0][1]
else
let s:triger = snips[trig]
endif
 
let l:abbr = substitute(
\ substitute(s:triger, '\n', '', 'g'),
\ '\s', ' ', 'g')
let l:menu = printf(l:menu_pattern, trig)
let list += [{'word' : trig, 'menu' : l:menu, 'abbr' : l:abbr}]
endfor
 
let s:snip_list[ft] = list
return neocomplcache#keyword_filter(copy(list), a:cur_keyword_str)
endfunction
 
function! neocomplcache#sources#snipMate_complete#define()
return s:source
endfunction

On 2011-10-10 the g:neocomplcache_max_filename_width variable was renamed to g:neocomplcache_max_menu_width so in order to use this Gist you should rename that variable in the code as well

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.