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

View File

@ -217,6 +217,14 @@ EXTENSIONS *airline-extensions*
Most extensions are enabled by default and lazily loaded when the Most extensions are enabled by default and lazily loaded when the
corresponding plugin (if any) is detected. 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* ------------------------------------- *airline-default*
The default extension understands all of the `g:` variables in the The default extension understands all of the `g:` variables in the
|airline-configuration| section, however it also has some more fine-tuned |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' ] \ [ 'x', 'y', 'z', 'warning' ]
\ ]) \ ])
< <
------------------------------------- *airline-quickfix* ------------------------------------- *airline-quickfix*
The quickfix extension is a simple built-in extension which determines The quickfix extension is a simple built-in extension which determines
whether the buffer is a quickfix or location list buffer, and adjusts the whether the buffer is a quickfix or location list buffer, and adjusts the