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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user