virtualenv: Enable for additional filetypes beside python

So with https://github.com/jmcantrell/vim-virtualenv you can display the
virtualenv in your statusline section (if you have enabled it). However
it would only become active for python buffers.

Now perhaps you want to show the virtualenv also in other filetypes like
markdown or CI scripts, so allow this by adding a variable
`airline#extensions#virtualenv#ft'` to the list of filetypes you want to
have enabled. So set:

    let g:airline#extensions#virtualenv#enabled = 1
    let g:airline#extensions#virtualenv#ft = ['python', 'markdown']

To allow displaying the virtual environment for python and markdown
buffers (but remember you need to have the plugin
https://github.com/jmcantrell/vim-virtualenv installed as well!)

fixes #2483
This commit is contained in:
Christian Brabandt 2021-12-08 11:23:42 +01:00
parent 8e36c0a8ed
commit bf5d785932
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 6 additions and 2 deletions

View File

@ -11,7 +11,7 @@ function! airline#extensions#virtualenv#init(ext)
endfunction
function! airline#extensions#virtualenv#apply(...)
if &filetype =~# "python"
if match(get(g:, 'airline#extensions#virtualenv#ft', ['python']), &filetype) > -1
if get(g:, 'virtualenv_loaded', 0)
let statusline = virtualenv#statusline()
else
@ -25,7 +25,7 @@ function! airline#extensions#virtualenv#apply(...)
endfunction
function! airline#extensions#virtualenv#update()
if &filetype =~# "python"
if match(get(g:, 'airline#extensions#virtualenv#ft', ['python']), &filetype) > -1
call airline#extensions#virtualenv#apply()
call airline#update_statusline()
endif

View File

@ -1538,6 +1538,10 @@ virtualenv <https://github.com/jmcantrell/vim-virtualenv>
* enable/disable virtualenv integration >
let g:airline#extensions#virtualenv#enabled = 1
<
* enable virtualenv for additional filetypes:
(default: python): >
let g:airline#extensions#virtualenv#ft = ['python', 'markdown']
<
------------------------------------- *airline-vista*
vista.vim <https://github.com/liuchengxu/vista.vim>