mirror of
https://github.com/gryf/snipmate.vim.git
synced 2025-12-19 20:38:05 +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.txt* Plugin for using TextMate-style snippets in Vim.
|
||||||
|
|
||||||
snipMate *snippet* *snippets* *snipMate*
|
snipMate *snippet* *snippets* *snipMate*
|
||||||
Last Change: July 13, 2009
|
Last Change: December 27, 2009
|
||||||
|
|
||||||
|snipMate-description| Description
|
|snipMate-description| Description
|
||||||
|snipMate-syntax| Snippet syntax
|
|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:
|
multiple matches, it should look like this:
|
||||||
'snippets/<filetype>/<trigger>/<name>.snippet' (see |multi_snip|).
|
'snippets/<filetype>/<trigger>/<name>.snippet' (see |multi_snip|).
|
||||||
|
|
||||||
*ResetSnippets()*
|
ResetAllSnippets() *ResetAllSnippets()*
|
||||||
The ResetSnippets() function removes all snippets from memory. This is useful
|
ResetAllSnippets() removes all snippets from memory. This is useful to put at
|
||||||
to put at the top of a snippet setup file for if you would like to |:source|
|
the top of a snippet setup file for if you would like to |:source| it multiple
|
||||||
it multiple times.
|
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>*
|
*list-snippets* *i_CTRL-R_<Tab>*
|
||||||
If you would like to see what snippets are available, simply type <c-r><tab>
|
If you would like to see what snippets are available, simply type <c-r><tab>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
" File: snipMate.vim
|
" File: snipMate.vim
|
||||||
" Author: Michael Sanders
|
" Author: Michael Sanders
|
||||||
" Version: 0.83
|
" Version: 0.84
|
||||||
" Description: snipMate.vim implements some of TextMate's snippets features in
|
" Description: snipMate.vim implements some of TextMate's snippets features in
|
||||||
" Vim. A snippet is a piece of often-typed text that you can
|
" 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>".
|
" insert into your document using a trigger word followed by a "<tab>".
|
||||||
@@ -91,10 +91,35 @@ fun! ExtractSnipsFile(file, ft)
|
|||||||
endfor
|
endfor
|
||||||
endf
|
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 = {}
|
let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {}
|
||||||
endf
|
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 = {}
|
let g:did_ft = {}
|
||||||
fun! GetSnippets(dir, filetypes)
|
fun! GetSnippets(dir, filetypes)
|
||||||
for ft in split(a:filetypes, '\.')
|
for ft in split(a:filetypes, '\.')
|
||||||
@@ -147,7 +172,7 @@ fun! TriggerSnippet()
|
|||||||
" the snippet.
|
" the snippet.
|
||||||
if snippet != ''
|
if snippet != ''
|
||||||
let col = col('.') - len(trigger)
|
let col = col('.') - len(trigger)
|
||||||
sil exe 's/\V'.escape(trigger, '/.').'\%#//'
|
sil exe 's/\V'.escape(trigger, '/\.').'\%#//'
|
||||||
return snipMate#expandSnip(snippet, col)
|
return snipMate#expandSnip(snippet, col)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
Reference in New Issue
Block a user