provide option to disable runtimepath extension loading. resolves #483

This commit is contained in:
Bailey Ling 2014-04-19 14:38:02 -04:00
parent e49eac95a3
commit fafb9ea76e
2 changed files with 26 additions and 17 deletions

View File

@ -207,22 +207,24 @@ function! airline#extensions#load()
call airline#extensions#promptline#init(s:ext)
endif
" Load all other extensions, which are not part of the default distribution.
" (autoload/airline/extensions/*.vim outside of our s:script_path).
for file in split(globpath(&rtp, "autoload/airline/extensions/*.vim"), "\n")
" we have to check both resolved and unresolved paths, since it's possible
" that they might not get resolved properly (see #187)
if stridx(tolower(resolve(fnamemodify(file, ':p'))), s:script_path) < 0
\ && stridx(tolower(fnamemodify(file, ':p')), s:script_path) < 0
let name = fnamemodify(file, ':t:r')
if !get(g:, 'airline#extensions#'.name.'#enabled', 1)
continue
if !get(g:, 'airline#extensions#disable_rtp_load', 0)
" load all other extensions, which are not part of the default distribution.
" (autoload/airline/extensions/*.vim outside of our s:script_path).
for file in split(globpath(&rtp, "autoload/airline/extensions/*.vim"), "\n")
" we have to check both resolved and unresolved paths, since it's possible
" that they might not get resolved properly (see #187)
if stridx(tolower(resolve(fnamemodify(file, ':p'))), s:script_path) < 0
\ && stridx(tolower(fnamemodify(file, ':p')), s:script_path) < 0
let name = fnamemodify(file, ':t:r')
if !get(g:, 'airline#extensions#'.name.'#enabled', 1)
continue
endif
try
call airline#extensions#{name}#init(s:ext)
catch
endtry
endif
try
call airline#extensions#{name}#init(s:ext)
catch
endtry
endif
endfor
endfor
endif
endfunction

View File

@ -217,6 +217,14 @@ EXTENSIONS *airline-extensions*
Most extensions are enabled by default and lazily loaded when the
corresponding plugin (if any) is detected.
By default, airline will attempt to load any extension it can find in the
'runtimepath'. On some systems this can result in an undersirable startup
cost. You can disable the check with the following flag. >
let g:airline#extensions#disable_rtp_load = 1
<
Note: Third party plugins that rely on this behavior will be affected. You
will need to manually load them.
------------------------------------- *airline-default*
The default extension understands all of the `g:` variables in the
|airline-configuration| section, however it also has some more fine-tuned
@ -240,7 +248,6 @@ configuration values that you can use.
\ [ 'x', 'y', 'z', 'warning' ]
\ ])
<
------------------------------------- *airline-quickfix*
The quickfix extension is a simple built-in extension which determines
whether the buffer is a quickfix or location list buffer, and adjusts the