Skip to content

Instantly share code, notes, and snippets.

@thinca
Created April 22, 2009 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thinca/99936 to your computer and use it in GitHub Desktop.
Save thinca/99936 to your computer and use it in GitHub Desktop.
*** 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
" A plugin for neocomplecache to complete snipMate snippets.
" Version: 0.0
" Author : thinca <http://d.hatena.ne.jp/thinca/>
" License: Creative Commons Attribution 2.1 Japan License
" <http://creativecommons.org/licenses/by/2.1/jp/deed.en>
let s:save_cpo = &cpo
set cpo&vim
function! neocomplcache#snipMate_complete#initialize() "{{{
" Initialize
let s:snip_list = {}
endfunction "}}}
function! neocomplcache#snipMate_complete#finalize() "{{{
endfunction "}}}
function! neocomplcache#snipMate_complete#get_keyword_list(cur_keyword_str) "{{{
let snips = GetSnippetsList(&filetype)
if empty(snips)
return []
endif
let ft = empty(&filetype) ? '_' : &filetype
if !has_key(s:snip_list, ft)
let list = []
for trig in keys(snips)
let list += [{'word' : trig, 'menu' : '[snipMate]', 'prev_word' : ['^'],
\ 'rank' : 1, 'prev_rank' : 0, 'prepre_rank' : 0, 'abbr' : trig}]
endfor
let s:snip_list[ft] = list
else
let list = s:snip_list[ft]
endif
return neocomplcache#keyword_filter(copy(list), a:cur_keyword_str)
endfunction "}}}
" Dummy function.
function! neocomplcache#snipMate_complete#calc_rank(cache_keyword_buffer_list) "{{{
endfunction "}}}
function! neocomplcache#snipMate_complete#calc_prev_rank(cache_keyword_buffer_list, prev_word, prepre_word) "{{{
endfunction "}}}
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: foldmethod=marker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment