1
0
mirror of https://github.com/gryf/snipmate.vim.git synced 2025-12-21 21:37:59 +01:00

added functions for resetting and reloading snippets

This commit is contained in:
msanders
2009-12-27 21:52:15 -05:00
parent 63a7255a21
commit 504fcdf50b
2 changed files with 43 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
" File: snipMate.vim
" Author: Michael Sanders
" Version: 0.83
" Version: 0.84
" Description: snipMate.vim implements some of TextMate's snippets features in
" Vim. A snippet is a piece of often-typed text that you can
" insert into your document using a trigger word followed by a "<tab>".
@@ -91,10 +91,35 @@ fun! ExtractSnipsFile(file, ft)
endfor
endf
fun! ResetSnippets()
" Reset snippets for filetype.
fun! ResetSnippets(ft)
let ft = a:ft == '' ? '_' : a:ft
for dict in [s:snippets, s:multi_snips, g:did_ft]
if has_key(dict, ft)
unlet dict[ft]
endif
endfor
endf
" Reset snippets for all filetypes.
fun! ResetAllSnippets()
let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {}
endf
" Reload snippets for filetype.
fun! ReloadSnippets(ft)
let ft = a:ft == '' ? '_' : a:ft
call ResetSnippets(ft)
call GetSnippets(g:snippets_dir, ft)
endf
" Reload snippets for all filetypes.
fun! ReloadAllSnippets()
for ft in keys(g:did_ft)
call ReloadSnippets(ft)
endfor
endf
let g:did_ft = {}
fun! GetSnippets(dir, filetypes)
for ft in split(a:filetypes, '\.')
@@ -147,7 +172,7 @@ fun! TriggerSnippet()
" the snippet.
if snippet != ''
let col = col('.') - len(trigger)
sil exe 's/\V'.escape(trigger, '/.').'\%#//'
sil exe 's/\V'.escape(trigger, '/\.').'\%#//'
return snipMate#expandSnip(snippet, col)
endif
endfor