1
0
mirror of https://github.com/gryf/snipmate.vim.git synced 2026-02-17 14:15: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:
Martin Grenfell
2009-02-27 18:03:58 +08:00
committed by meese
parent dd4836d2b2
commit b5999ba5cc
2 changed files with 17 additions and 11 deletions

View File

@@ -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