cfg-pre - Support loading plugin configuration before or after the plugin
This commit is contained in:
parent
725add3819
commit
d17ae721a1
1 changed files with 16 additions and 14 deletions
|
@ -26,21 +26,30 @@ if has( 'vim_starting' )
|
|||
if &compatible
|
||||
set nocompatible
|
||||
endif
|
||||
|
||||
let s:dein_path = g:bundles_dir . "github.com/Shougo/dein.vim"
|
||||
let s:dein_path = g:bundles_dir . "repos/github.com/Shougo/dein.vim"
|
||||
if !isdirectory(s:dein_path)
|
||||
execute '!git clone https://github.com/Shougo/dein.vim' s:dein_path
|
||||
endif
|
||||
let &g:runtimepath = &g:runtimepath . "," . s:dein_path
|
||||
endif
|
||||
|
||||
" Function that sets a hook to be executed before or after a plugin is loaded.
|
||||
function! LoadPluginHook(plugins_dir, pname, hook, file_ext)
|
||||
let l:cfgfile = GetConfigFilePath( a:plugins_dir ,
|
||||
\ s:pname . "." . a:file_ext . ".vim" )
|
||||
if l:cfgfile != ""
|
||||
call dein#set_hook(a:pname, "hook_" . a:hook,
|
||||
\ join(readfile(l:cfgfile), "\n")
|
||||
\ )
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Start initializing plugins
|
||||
call dein#begin( g:bundles_dir )
|
||||
call dein#options(#{
|
||||
\ lazy_plugins: v:true,
|
||||
\ install_progress_type: 'floating',
|
||||
\ })
|
||||
call dein#begin( g:bundles_dir )
|
||||
|
||||
" Load Dein itself
|
||||
call dein#add(s:dein_path)
|
||||
|
||||
" Load all plugins from ${plugins directory}/*.load.vim
|
||||
|
@ -50,19 +59,12 @@ let s:bundle_load_files = GetConfigFiles( s:plugins_dir , "*.load.vim" )
|
|||
for s:plfn in values( s:bundle_load_files )
|
||||
execute "source" s:plfn
|
||||
|
||||
" Create configuration loading hooks
|
||||
let s:pname = fnamemodify( s:plfn , ":t:r:r" )
|
||||
let s:cfgfile = GetConfigFilePath( s:plugins_dir ,
|
||||
\ s:pname . ".cfg.vim" )
|
||||
if s:cfgfile != ""
|
||||
call dein#set_hook(s:pname, 'hook_post_source',
|
||||
\ join(readfile(s:cfgfile), "\n")
|
||||
\ )
|
||||
endif
|
||||
call LoadPluginHook(s:plugins_dir, s:pname, "source", "cfg")
|
||||
call LoadPluginHook(s:plugins_dir, s:pname, "post_source", "post")
|
||||
endfor
|
||||
|
||||
call dein#end()
|
||||
autocmd VimEnter * call dein#call_hook('post_source')
|
||||
|
||||
function! CheckDeinInstall()
|
||||
" Let Dein check for installations
|
||||
|
|
Loading…
Reference in a new issue