Created
June 6, 2010 23:07
-
-
Save rmax/428009 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! EnableVirtualEnv() | |
python << EOF | |
import vim | |
import os | |
import sys | |
if 'VIRTUAL_ENV' in os.environ: | |
vim.command('let g:virtualenv_found = 1') | |
# enable virtualenv environment within vimruntime | |
activate_this = os.path.join(os.environ['VIRTUAL_ENV'], 'bin/activate_this.py') | |
if os.path.isfile(activate_this): | |
execfile(activate_this, dict(__file__=activate_this)) | |
vim.command('let g:virtualenv_enabled = 1') | |
else: | |
vim.command('let g:virtualenv_enabled = 0') | |
# allow to have custom vimrc per virtualenv | |
vimrc = os.path.join(os.environ['VIRTUAL_ENV'], '.vimrc') | |
if os.path.isfile(vimrc): | |
vim.command('source %s' % vimrc) | |
vim.command('let g:virtualenv_vimrc = 1') | |
else: | |
vim.command('let g:virtualenv_vimrc = 0') | |
else: | |
vim.command('let g:virtualenv_found = 0') | |
EOF | |
endfunction | |
call EnableVirtualEnv() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment