mirror of
https://github.com/gryf/snipmate.vim.git
synced 2025-12-19 04:20:18 +01:00
added functions for resetting and reloading snippets
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
*snipMate.txt* Plugin for using TextMate-style snippets in Vim.
|
||||
|
||||
snipMate *snippet* *snippets* *snipMate*
|
||||
Last Change: July 13, 2009
|
||||
Last Change: December 27, 2009
|
||||
|
||||
|snipMate-description| Description
|
||||
|snipMate-syntax| Snippet syntax
|
||||
@@ -198,10 +198,20 @@ look like this: 'snippets/<filetype>/<trigger>.snippet'. If the snippet has
|
||||
multiple matches, it should look like this:
|
||||
'snippets/<filetype>/<trigger>/<name>.snippet' (see |multi_snip|).
|
||||
|
||||
*ResetSnippets()*
|
||||
The ResetSnippets() function removes all snippets from memory. This is useful
|
||||
to put at the top of a snippet setup file for if you would like to |:source|
|
||||
it multiple times.
|
||||
ResetAllSnippets() *ResetAllSnippets()*
|
||||
ResetAllSnippets() removes all snippets from memory. This is useful to put at
|
||||
the top of a snippet setup file for if you would like to |:source| it multiple
|
||||
times.
|
||||
|
||||
ResetSnippets({filetype}) *ResetSnippets()*
|
||||
ResetSnippets() removes all snippets from memory for the given filetype.
|
||||
|
||||
ReloadAllSnippets() *ReloadAllSnippets()*
|
||||
ReloadAllSnippets() reloads all snippets for all filetypes. This is useful for
|
||||
testing and debugging.
|
||||
|
||||
ReloadSnippets({filetype}) *ReloadAllSnippets()*
|
||||
ReloadSnippets() reloads all snippets for the given filetype.
|
||||
|
||||
*list-snippets* *i_CTRL-R_<Tab>*
|
||||
If you would like to see what snippets are available, simply type <c-r><tab>
|
||||
|
||||
@@ -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