You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is there a way of adding a specific addon after vim is already started? #78
There are some plugins that I rarely use but when I need to use them I first have to edit my vimrc and remove them from the list of disabled plugins and start vim again.
Would it be possible to have a function either in pathogen, or based on pathogen that would allow the following:
Probably possible, but super tricky. The first challenge is to add it to the runtime path. What position does it belong in? The OCD part of me wants to inject it into the exact spot it would have appeared if it had been loaded with Vim. But I guess we could get by with something more predictable.
The harder part is actually loading plugins after they've been added. Do we :source them? :runtime them? Do we need to dispatch any autocmds?
The harder part is actually loading plugins after they've been added.
Indeed. In general, you need plugin-specific code for that. For example, YouCompleteMe is bootstrapped through a function called on a VimEnter event, which needs to be called manually if the plugin is loaded later.
Anyway, I have this code in my .vimrc, which mostly does what the OP is asking for:
" Enable a blacklisted plugin.
fun! s:loadPlugin(plugin_name)
" Remove the plugin from Pathogen's blacklist
call filter(g:pathogen_blacklist, "v:val !=? '" . a:plugin_name ."'")
" Update runtimepath
call pathogen#surround($HOME . "/.vim/bundle/" . tolower(a:plugin_name))
" Load the plugin
" Note that this loads only one file (which is usually fine):
runtime plugin/*.vim
" Note that this uses the plugin name as typed by the user:
execute 'runtime! after/plugin/**/' . a:plugin_name . '.vim'
" Plugin-specific activation
if tolower(a:plugin_name) == 'youcompleteme'
call youcompleteme#Enable()
endif
endf
" See h :command
fun! s:loadPluginCompletion(argLead, cmdLine, cursorPos)
return filter(copy(g:pathogen_blacklist), "v:val =~? '^" . a:argLead . "'")
endf
command! -nargs=1 -complete=customlist,s:loadPluginCompletion LoadPlugin call <sid>loadPlugin(<q-args>)
Activity
tpope commentedon Jan 1, 2013
Probably possible, but super tricky. The first challenge is to add it to the runtime path. What position does it belong in? The OCD part of me wants to inject it into the exact spot it would have appeared if it had been loaded with Vim. But I guess we could get by with something more predictable.
The harder part is actually loading plugins after they've been added. Do we
:sourcethem?:runtimethem? Do we need to dispatch any autocmds?lifepillar commentedon Sep 20, 2015
Indeed. In general, you need plugin-specific code for that. For example, YouCompleteMe is bootstrapped through a function called on a
VimEnterevent, which needs to be called manually if the plugin is loaded later.Anyway, I have this code in my
.vimrc, which mostly does what the OP is asking for: