Reputation: 651
When I check my .vim
directory, I found that all the plugins installed with vim-plug
is sitting in the .vim/plugged
directory. In this case, how did vim load these plugins? If I have a same plugin normally installed, then which one will have a higher propriety to be loaded?
Upvotes: 1
Views: 154
Reputation: 40832
The plug#begin(...)
function sets the "home" path for the plugin (vim-plug
is a plugin too),
if a:0 > 0
let s:plug_home_org = a:1
let home = s:path(fnamemodify(expand(a:1), ':p'))
...
and the function plug#end()
goes through the list of plugins defined (via plug#()
), and keeps them in a dictionary:
for name in g:plugs_order
...
if has_key(plug, 'on')
let s:triggers[name] = { 'map': [], 'cmd': [] }
for cmd in s:to_a(plug.on)
if cmd =~? '^<Plug>.\+'
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
call s:assoc(lod.map, cmd, name)
then finally manipulates the runtimepath
and source
s each one of the plugins by calling (eventually) s:lod()
:
for [cmd, names] in items(lod.cmd)
execute printf(
\ 'command! -nargs=* -range -bang %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)',
\ cmd, string(cmd), string(names))
endfor
You can figure out the order in which plugins are loaded from vim-plug
's code.
Upvotes: 1
Reputation: 195029
Loading a plugin is nothing more than sourcing the script file(s). The script file could be anywhere.
Usually a plugin has a flag (g:variable e.g.) to detect if the script is already loaded. So it won't be loaded twice. However, if your plugin doesn't have this mechanism, it could be loaded twice.
Upvotes: 0