From f0df8825df89b4183ea3aafbb61e0ee159ae51b3 Mon Sep 17 00:00:00 2001 From: joe di castro Date: Sat, 24 Aug 2013 22:49:54 +0200 Subject: [PATCH] add virtualenv extension --- README.md | 6 +++++- autoload/airline/extensions.vim | 4 ++++ autoload/airline/extensions/virtualenv.vim | 13 +++++++++++++ doc/airline.txt | 8 +++++++- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 autoload/airline/extensions/virtualenv.vim diff --git a/README.md b/README.md index ef4631cb..806960cb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Lean & mean statusline for vim that's light as air. # Features * tiny core written with extensibility in mind ([open/closed principle][8]). -* integrates with a variety of plugins, including: [vim-bufferline][6], [fugitive][4], [unite][9], [ctrlp][10], [minibufexpl][15], [gundo][16], [undotree][17], [nerdtree][18], [tagbar][19], [vim-gitgutter][29], [vim-signify][30], [syntastic][5] and [lawrencium][21]. +* integrates with a variety of plugins, including: [vim-bufferline][6], [fugitive][4], [unite][9], [ctrlp][10], [minibufexpl][15], [gundo][16], [undotree][17], [nerdtree][18], [tagbar][19], [vim-gitgutter][29], [vim-signify][30], [syntastic][5], [lawrencium][21] and [virtualenv][31] * looks good with regular fonts and provides configuration points so you can use unicode or powerline symbols. * optimized for speed; it loads in under a millisecond. * extensive suite of themes for popular colorschemes including [solarized][23] (dark and light), [tomorrow][24] (all variants), [molokai][25], [jellybeans][26] and others; have a look at the [screenshots][14] in the wiki. @@ -48,6 +48,9 @@ vim-airline provides seamless integration with a variety of plugins. These exte ### hunks ([vim-gitgutter][29] & [vim-signify][30]) ![image](https://f.cloud.github.com/assets/306502/995185/73fc7054-09b9-11e3-9d45-618406c6ed98.png) +### [virtualenv][31] +![image](https://f.cloud.github.com/assets/390964/1021386/73ed49e4-0cfc-11e3-96df-8d5084cde7da.png) + # Rationale There's already [powerline][2], why yet another statusline? @@ -151,3 +154,4 @@ MIT license. Copyright (c) 2013 Bailey Ling. [28]: https://github.com/chrisbra/csv.vim [29]: https://github.com/airblade/vim-gitgutter [30]: https://github.com/mhinz/vim-signify +[31]: https://github.com/jmcantrell/vim-virtualenv diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 3d2d5ab1..ed222d00 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -161,6 +161,10 @@ function! airline#extensions#load() call airline#extensions#bufferline#init(s:ext) endif + if (get(g:, 'virtualenv_loaded', 1) && get(g:, 'airline_enable_virtualenv', 1)) + call airline#extensions#virtualenv#init(s:ext) + endif + if g:airline_section_warning == '__' if (get(g:, 'airline#extensions#syntastic#enabled', 1) && get(g:, 'airline_enable_syntastic', 1)) \ && exists(':SyntasticCheck') diff --git a/autoload/airline/extensions/virtualenv.vim b/autoload/airline/extensions/virtualenv.vim new file mode 100644 index 00000000..a4517a9d --- /dev/null +++ b/autoload/airline/extensions/virtualenv.vim @@ -0,0 +1,13 @@ +" MIT License. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +function! airline#extensions#virtualenv#init(ext) + call a:ext.add_statusline_func('airline#extensions#virtualenv#apply') +endfunction + +function! airline#extensions#virtualenv#apply(...) + if &filetype == "python" + let w:airline_section_x = '%{virtualenv#statusline()} '.g:airline_section_x + endif +endfunction + diff --git a/doc/airline.txt b/doc/airline.txt index 290a546b..21fb6544 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -169,7 +169,7 @@ extension. let g:airline_section_b (the fugitive/lawrencium branch indicator) let g:airline_section_c (bufferline or filename) let g:airline_section_gutter (readonly, csv) - let g:airline_section_x (tagbar, filetype) + let g:airline_section_x (tagbar, virtualenv, filetype) let g:airline_section_y (fileencoding, fileformat) let g:airline_section_z (percentage, line number, column number) let g:airline_section_warning (syntastic, whitespace) @@ -253,6 +253,12 @@ ctrlp let g:airline#extensions#ctrlp#color_template = 'visual' let g:airline#extensions#ctrlp#color_template = 'replace' < + *airline-virtualenv* + +virtualenv + +* enable/disable virtualenv integration > + let g:airline#extensions#virtualenv#enabled = 1 ============================================================================== FUNCREFS *airline-funcrefs*