mirror of
https://github.com/gryf/snipmate.vim.git
synced 2026-02-17 05:55:45 +01:00
bugfix: dont source file based snippets more than once
Set the s:did_<filetype> flag after reading in file based snippets. This prevents snippets getting read in more than once. Move the code that checks for file based snippets out of after/plugin/snipMate.vim and into plugin/snipMate.vim. Refactor this code into functions for readability. Signed-off-by: meese <msanders42@gmail.com>
This commit is contained in:
@@ -21,6 +21,23 @@ com! -nargs=+ -bang GlobalSnip call s:MakeSnippet(<q-args>, '_', <bang>0)
|
||||
|
||||
let s:snippets = {} | let s:multi_snips = {}
|
||||
|
||||
"read in file based snippets for each filetype as we encounter the filetype
|
||||
au FileType * call s:CheckForSnippets()
|
||||
fun! s:CheckForSnippets()
|
||||
if !exists('s:did_'.&ft) && isdirectory($HOME.'/.vim/snippets/'.&ft)
|
||||
cal ExtractSnips($HOME.'/.vim/snippets/'.&ft, &ft)
|
||||
let s:did_{&ft} = 1
|
||||
en
|
||||
endf
|
||||
|
||||
"read in the global file based snippets after vim starts
|
||||
au VimEnter * call s:ReadGlobalSnippets()
|
||||
fun! s:ReadGlobalSnippets()
|
||||
if isdirectory($HOME.'/.vim/snippets/_')
|
||||
call ExtractSnips($HOME.'/.vim/snippets/_', '_')
|
||||
endif
|
||||
endf
|
||||
|
||||
fun! Filename(...)
|
||||
let filename = expand('%:t:r')
|
||||
if filename == '' | return a:0 == 2 ? a:2 : '' | endif
|
||||
|
||||
Reference in New Issue
Block a user