Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

Commit

Permalink
support snipmate
Browse files Browse the repository at this point in the history
  • Loading branch information
roxma committed Mar 12, 2017
1 parent c2ef34f commit 44f2ad8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Subscribe it if you are interested.**
3. Smarter on files with different languages, for example, css/javascript
completion in html style/script tag.
4. Extensible async vimscript API and python3 API.
5. Function parameter expansion via ultisnips/neosnippet engine.
5. Function parameter expansion via ultisnips,neosnippet or snipmate.


## Available Completion Sources
Expand All @@ -50,7 +50,7 @@ plugin builtin sources:
- Keyword from current buffer
- Tag completion. (`:help 'tags'`, `:help tagfiles()`)
- Keyword from tmux session
- Ultisnips or neosnippet hint, which requires ultisnips or neosnippet.
- Ultisnips, neosnippet or snipmate hint, when you've installed one of them.
- File path completion
- Python completion via [jedi](https://github.com/davidhalter/jedi)
- Css completion via vim's builtin
Expand Down
15 changes: 15 additions & 0 deletions autoload/cm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,25 @@ func! s:check_and_inject_snippet()
exec g:_uspy 'UltiSnips_Manager._added_snippets_source._snippets["ncm"]._snippets = []'
" TODO cleanup when InsertLeave
call UltiSnips#AddSnippetWithPriority(v:completed_item.word, v:completed_item.snippet, '', 'i', b:_cm_us_filetype, 1)
elseif g:cm_completed_snippet_engine == 'snipmate'
if !exists('s:completed_item')
let s:completed_item = {}
autocmd InsertLeave * let s:completed_item = {}
" inject ncm's handler into snipmate
let g:snipMateSources['ncm'] = funcref#Function('cm#_snipmate_snippets')
endif
let s:completed_item = v:completed_item
endif

endfunc

func! cm#_snipmate_snippets(scopes, trigger, result)
if empty(s:completed_item)
return
endif
let a:result[s:completed_item['word']] = {'default': [s:completed_item.snippet,0] }
endfunc

" on completion context changed
func! s:on_changed()

Expand Down
3 changes: 3 additions & 0 deletions plugin/cm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func! s:lazy_init()
elseif exists('g:did_plugin_ultisnips')
let g:cm_completed_snippet_enable = 1
let g:cm_completed_snippet_engine = 'ultisnips'
elseif exists('g:snipMateSources')
let g:cm_completed_snippet_enable = 1
let g:cm_completed_snippet_engine = 'snipmate'
else
let g:cm_completed_snippet_enable = 0
let g:cm_completed_snippet_engine = ''
Expand Down

0 comments on commit 44f2ad8

Please sign in to comment.