Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Enable lazy loading of plugins.
Browse files Browse the repository at this point in the history
Pathogen has a g:pathogen_blacklist variable that may be used to specify
a list of plugins that should not be loaded at startup (btw, it also
supports an undocumented $VIMBLACKLIST variable to temporarily disable
plugins). Currently, I use that list to disable YouCompleteMe, which
significantly increases the startup time, and which I need only when
using some programming languages (e.g., Python).

Enabling plugins at runtime is “super-tricky” in general:

    tpope/vim-pathogen#78

(YCM being a good example, since it requires to call a function to
enable it), but I don’t need a completely general approach in my
personal vimrc, so s:loadPlugin() should be good enough.
  • Loading branch information
Lifepillar committed Sep 20, 2015
1 parent 9f84b35 commit 44ca797
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
filetype plugin on " Enable loading the plugin files for specific file types.
filetype indent on " Load indent files for specific file types.
runtime bundle/pathogen/autoload/pathogen.vim " Load Pathogen.
let g:pathogen_blacklist = ['youcompleteme']
execute pathogen#infect()
set sessionoptions-=options " See FAQ at https://github.com/tpope/vim-pathogen.
set autoread " Re-read file if it is changed by an external program.
Expand Down Expand Up @@ -67,6 +68,22 @@
echohl NONE
endf

" 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
runtime plugin/**/*.vim
" Plugin-specific activation
if tolower(a:plugin_name) == 'youcompleteme'
call youcompleteme#Enable()
endif
endf

command! -nargs=1 LoadPlugin call <sid>loadPlugin(<q-args>)

" Set the tab width in the current buffer (see also http://vim.wikia.com/wiki/Indenting_source_code).
fun! s:setLocalTabWidth(w)
let l:twd = a:w > 0 ? a:w : 1 " Disallow non-positive width
Expand Down

0 comments on commit 44ca797

Please sign in to comment.