Skip to content

Instantly share code, notes, and snippets.

@cooldaemon
Created July 9, 2010 11:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cooldaemon/469369 to your computer and use it in GitHub Desktop.
Save cooldaemon/469369 to your computer and use it in GitHub Desktop.
neocomplcache + zencoding
*** zencoding.vim.org 2010-07-09 12:07:33.000000000 +0900
--- zencoding.vim 2010-07-09 20:00:47.000000000 +0900
***************
*** 2131,2134 ****
--- 2131,2143 ----
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
endfunction
+ function g:get_zen_snippets_list(type)
+ let type = a:type
+ if !has_key(s:zen_settings, type)
+ let type = 'html'
+ endif
+ if len(type) == 0 | let type = 'html' | endif
+ return s:zen_getResource(type, 'snippets', {})
+ endfunction
+
" vim:set et:
let s:source = {
\ 'name' : 'zencoding_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 = g:get_zen_snippets_list(ft)
if empty(snips)
return []
endif
let l:abbr_pattern = printf('%%.%ds..%%s', g:neocomplcache_max_keyword_width-10)
let l:menu_pattern = '<Z> %.'.g:neocomplcache_max_filename_width.'s'
let list = []
for trig in keys(snips)
let s:triger = snips[trig]
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#zencoding_complete#define()
return s:source
endfunction
@mattn
Copy link

mattn commented Jul 13, 2010

取り入れ検討します。最近仕事が忙しいのでちょっと時間下さい。

@cooldaemon
Copy link
Author

ありがとうございます!
Vim Shell に疎いので、zencoding と neocomplcache が連携するという発想だけ、お汲み取りいただければ幸いです。

@mattn
Copy link

mattn commented May 31, 2012

いまさら感が抜群ですが(2 years ago ぇ)...

zencoding#getSnippets(type)

という形で取り込ませて頂きました。

@cooldaemon
Copy link
Author

cooldaemon commented May 31, 2012 via email

@UncleBill
Copy link

@cooldaemon
Could you make a plugin for neocomplcahce like vim-neco-calc

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