mirror of
https://github.com/gryf/snipmate.vim.git
synced 2026-01-05 21:34:13 +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:
@@ -11,14 +11,3 @@ snor <bs> b<bs>
|
|||||||
snor ' b<bs>'
|
snor ' b<bs>'
|
||||||
snor <right> <esc>a
|
snor <right> <esc>a
|
||||||
snor <left> <esc>bi
|
snor <left> <esc>bi
|
||||||
|
|
||||||
" By default load snippets in ~/.vim/snippets/<filetype>
|
|
||||||
" NOTE: I need to make sure this works on Windows
|
|
||||||
if isdirectory($HOME.'/.vim/snippets')
|
|
||||||
if isdirectory($HOME.'/.vim/snippets/_')
|
|
||||||
call ExtractSnips($HOME.'/.vim/snippets/_', '_')
|
|
||||||
endif
|
|
||||||
au FileType * if !exists('s:did_'.&ft) &&
|
|
||||||
\ isdirectory($HOME.'/.vim/snippets/'.&ft)
|
|
||||||
\| cal ExtractSnips($HOME.'/.vim/snippets/'.&ft, &ft) | en
|
|
||||||
endif
|
|
||||||
|
|||||||
@@ -21,6 +21,23 @@ com! -nargs=+ -bang GlobalSnip call s:MakeSnippet(<q-args>, '_', <bang>0)
|
|||||||
|
|
||||||
let s:snippets = {} | let s:multi_snips = {}
|
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(...)
|
fun! Filename(...)
|
||||||
let filename = expand('%:t:r')
|
let filename = expand('%:t:r')
|
||||||
if filename == '' | return a:0 == 2 ? a:2 : '' | endif
|
if filename == '' | return a:0 == 2 ? a:2 : '' | endif
|
||||||
|
|||||||
Reference in New Issue
Block a user