Skip to content

Instantly share code, notes, and snippets.

@cooldaemon
Forked from thinca/GetSnippetsList.diff
Created August 10, 2009 08:45
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cooldaemon/165090 to your computer and use it in GitHub Desktop.
Save cooldaemon/165090 to your computer and use it in GitHub Desktop.
neocomplcache + snipMate
*** 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
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
@teranex
Copy link

teranex commented Mar 3, 2012

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

@zagfai
Copy link

zagfai commented Jul 24, 2012

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment