From b763cae81a55baf089448d30e75d412c1db53094 Mon Sep 17 00:00:00 2001 From: "C.D. Clark III" Date: Sat, 29 Mar 2014 21:29:54 -0500 Subject: [PATCH] added plug load order (for dependencies) plugin directories now appear in the runtime path in the same order they are listed. this allows plugs that depend on other plugins to be loaded after their dependencies. --- plug.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plug.vim b/plug.vim index 29906d0..386f23d 100644 --- a/plug.vim +++ b/plug.vim @@ -88,6 +88,8 @@ function! plug#begin(...) let g:plug_home = home let g:plugs = {} + " we want to keep track of the order plugins where registered. + let g:plugs_order = [] command! -nargs=+ Plug call s:add(1, ) command! -nargs=* PlugInstall call s:install() @@ -110,7 +112,12 @@ function! plug#end() endwhile filetype off - for plug in values(g:plugs) + " we want to make sure the plugin directories are added to rtp in the same + " order that they are registered with the Plug command. since the s:add_rtp + " function uses ^= to add plugin directories to the front of the rtp, we + " need to loop through the plugins in reverse + for name in reverse(copy(g:plugs_order)) + let plug = g:plugs[name] if has_key(plug, 'on') let commands = type(plug.on) == 1 ? [plug.on] : plug.on for cmd in commands @@ -221,6 +228,7 @@ function! s:add(...) let dir = s:dirpath( fnamemodify(join([g:plug_home, name], '/'), ':p') ) let spec = extend(opts, { 'dir': dir, 'uri': uri }) let g:plugs[name] = spec + let g:plugs_order += [name] endfunction function! s:install(...)