Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

neocomplcache 提示 snipMate 补全

  • Loading branch information...
commit a9141bb0348e3ab180fc9f35bd9493efb2dd1e5c 1 parent b4449ec
依云 authored October 24, 2012
50  autoload/neocomplcache/sources/snipMate_complete.vim
... ...
@@ -0,0 +1,50 @@
  1
+let s:source = {
  2
+      \ 'name' : 'snipMate_complete',
  3
+      \ 'kind' : 'plugin',
  4
+      \}
  5
+
  6
+function! s:source.initialize()
  7
+  let s:snip_list = {}
  8
+endfunction
  9
+
  10
+function! s:source.finalize()
  11
+endfunction
  12
+
  13
+function! s:source.get_keyword_list(cur_keyword_str)
  14
+  let ft = neocomplcache#get_context_filetype()
  15
+
  16
+  if has_key(s:snip_list, ft)
  17
+    return neocomplcache#keyword_filter(copy(s:snip_list[ft]), a:cur_keyword_str)
  18
+  end
  19
+
  20
+  let snips = GetSnippetsList(ft)
  21
+  if empty(snips)
  22
+    return []
  23
+  endif
  24
+
  25
+  let l:abbr_pattern = printf('%%.%ds..%%s', g:neocomplcache_max_keyword_width-10)
  26
+  let l:menu_pattern = '<S> %.'.g:neocomplcache_max_menu_width.'s'
  27
+
  28
+  let list = []
  29
+  for trig in keys(snips)
  30
+    if type(snips[trig]) == type([])
  31
+      let s:triger = 'multi snips - ' . snips[trig][0][1]
  32
+    else
  33
+      let s:triger = snips[trig]
  34
+    endif
  35
+
  36
+    let l:abbr = substitute(
  37
+      \ substitute(s:triger, '\n', '', 'g'),
  38
+      \ '\s', ' ', 'g')
  39
+    let l:menu = printf(l:menu_pattern, trig)
  40
+    let list += [{'word' : trig, 'menu' : l:menu, 'abbr' : l:abbr}]
  41
+  endfor
  42
+
  43
+  let s:snip_list[ft] = list
  44
+  return neocomplcache#keyword_filter(copy(list), a:cur_keyword_str)
  45
+endfunction
  46
+
  47
+function! neocomplcache#sources#snipMate_complete#define()
  48
+  return s:source
  49
+endfunction
  50
+
11  plugin/snipMate.vim
@@ -272,4 +272,15 @@ fun! ShowAvailableSnips()
272 272
 	call complete(col, matches)
273 273
 	return ''
274 274
 endf
  275
+
  276
+fun GetSnippetsList(ft)
  277
+	let s = {}
  278
+	for i in ['s:snippets["_"]', 's:multi_snips["_"]',
  279
+		\ 's:snippets[a:ft]', 's:multi_snips[a:ft]']
  280
+		if exists(i)
  281
+			let s = extend(s, deepcopy(eval(i)))
  282
+		endif
  283
+	endfor
  284
+	return s
  285
+endf
275 286
 " vim:noet:sw=4:ts=4:ft=vim

0 notes on commit a9141bb

Please sign in to comment.
Something went wrong with that request. Please try again.