This repository was archived by the owner on Sep 1, 2023. It is now read-only.
forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvirtualenv.vim
More file actions
49 lines (37 loc) · 1.3 KB
/
virtualenv.vim
File metadata and controls
49 lines (37 loc) · 1.3 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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)
if g:pymode_py3k
" XXX these differences should better be moved into a common module. DRY violation.
python3 << EOF
import os
ve_dir = os.environ['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')
exec(compile(open(activate_this).read(), "activate_this.py", 'exec'), dict(__file__=activate_this))
EOF
else
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
endif
call pymode#WideMessage("Activate virtualenv: ".$VIRTUAL_ENV)
endif
endfunction "}}}