Merge pull request #652 from chenaren/venv_fallback

Add simple virtualenv fallback when vim-virtualenv is not presented
This commit is contained in:
Bailey Ling 2014-11-22 10:59:01 -05:00
commit 15666d71e3
2 changed files with 8 additions and 3 deletions

View File

@ -178,7 +178,7 @@ function! airline#extensions#load()
call airline#extensions#bufferline#init(s:ext)
endif
if get(g:, 'virtualenv_loaded', 0) && get(g:, 'airline#extensions#virtualenv#enabled', 1)
if isdirectory($VIRTUAL_ENV) && get(g:, 'airline#extensions#virtualenv#enabled', 1)
call airline#extensions#virtualenv#init(s:ext)
endif

View File

@ -1,7 +1,7 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !get(g:, 'virtualenv_loaded', 0)
if !isdirectory($VIRTUAL_ENV)
finish
endif
@ -13,8 +13,13 @@ endfunction
function! airline#extensions#virtualenv#apply(...)
if &filetype =~ "python"
if get(g:, 'virtualenv_loaded', 0)
let statusline = virtualenv#statusline()
else
let statusline = fnamemodify($VIRTUAL_ENV, ':t')
endif
call airline#extensions#append_to_section('x',
\ s:spc.g:airline_right_alt_sep.s:spc.'%{virtualenv#statusline()}')
\ s:spc.g:airline_right_alt_sep.s:spc.statusline)
endif
endfunction