Friday, August 24, 2012

Re: How to use virtualenv in Vim ?

On Fri, 24 Aug 2012, chris wrote:

> I added plugin virtualenv
> (https://github.com/jmcantrell/vim-virtualenv) into my runtimepath.
>
> I'm new to virtualenv. The Vim plugin virtualenv has a function for
> statusline show the virutalenv name. I added it into my statusline
> option like this:
> set statusline+=\ \%{virtualenv#statusline()}

You shouldn't set that. Powerline makes the 'statusline' option
irrelevant.


> And I also add this virtualenv segment into Powerline statusline.
> call Pl#Theme#InsertSegment('virtualenv', 'after', 'hgrev')

Powerline already has built-in support for virtualenv. But, if you're
using a non-standard theme or something, your call should be:

call Pl#Theme#InsertSegment('%{virtualenv#statusline()}', 'after', 'hgrev')


> I execute some commands:
> $ virtualenv test
> $ source bin/activate
> $ python bin/activate_this.py
> $ vim test.py
> Then I do not see the virtualenv name in statusline, both original
> statusline and Powerline statusline.

Virtualenv requires a Vim with Python support. Run: :version and look
for +python in the output. If it's not there, virtualenv won't work.
Based on the Powerline condition for including it¹, try (all one line):

:echo has('python') && (exists('g:virtualenv_loaded') && g:virtualenv_loaded == 1)

--
Best,
Ben H

¹: https://github.com/Lokaltog/vim-powerline/blob/develop/autoload/Powerline/Segments/virtualenv.vim

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment