forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirtualenv.vim
More file actions
31 lines (22 loc) · 758 Bytes
/
virtualenv.vim
File metadata and controls
31 lines (22 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
fun! pymode#virtualenv#Activate() "{{{
if !exists("$VIRTUAL_ENV")
return
endif
for env in g:pymode_virtualenv_enabled
if env == $VIRTUAL_ENV
return 0
endif
endfor
call add(g:pymode_virtualenv_enabled, $VIRTUAL_ENV)
python << EOF
import sys, vim, os
ve_dir = vim.eval('$VIRTUAL_ENV')
ve_dir in sys.path or sys.path.insert(0, ve_dir)
activate_this = os.path.join(os.path.join(ve_dir, 'bin'), 'activate_this.py')
# Fix for windows
if not os.path.exists(activate_this):
activate_this = os.path.join(os.path.join(ve_dir, 'Scripts'), 'activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
call pymode#WideMessage("Activate virtualenv: ".$VIRTUAL_ENV)
endfunction "}}}