Skip to content

Commit 8acb90c

Browse files
committed
Add virtualenv support
1 parent 24a9c81 commit 8acb90c

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

Changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
Changelog
22
=========
33

4-
## 2011-10-18 0.2.5
4+
## 2011-10-18 0.2.6
55
-------------------
66
* Add <C-space> shortcut for macvim users.
7+
* Add VIRTUALENV support
78

89
## 2011-10-17 0.2.4
910
-------------------

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ There is no need to install the pylint_ or rope_ library on your system.
1515
- Run python code
1616
- Go to definition
1717
- Powerful customization
18+
- Virtualenv support
1819
- And more...
1920

2021
See screencast here: http://t.co/3b0bzeXA (sorry for quality, this my first screencast)
@@ -151,6 +152,9 @@ Default values: ::
151152
" Autoremove unused whitespaces
152153
let g:pymode_utils_whitespaces = 1
153154

155+
" Auto fix vim python paths if virtualenv enabled
156+
let g:pymode_virtualenv = 1
157+
154158
.. note:: See also :help ropevim.txt
155159

156160

after/plugin/pymode_virtualenv.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
" OPTION: g:pymode_lint -- bool. Load pylint plugin
2+
call helpers#SafeVar("g:pymode_virtualenv", 1)
3+
4+
" DESC: Disable script loading
5+
if !g:pymode_virtualenv || !g:pymode
6+
let g:pymode_virtualenv = 0
7+
finish
8+
endif
9+
10+
fun! pymode_virtualenv#Activate() "{{{
11+
python << EOF
12+
ve_dir = os.environ['VIRTUAL_ENV']
13+
ve_dir in sys.path or sys.path.insert(0, ve_dir)
14+
activate_this = os.path.join(os.path.join(ve_dir, 'bin'), 'activate_this.py')
15+
execfile(activate_this, dict(__file__=activate_this))
16+
EOF
17+
endfunction "}}}

doc/pymode.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ PythonMode. These options should be set in your vimrc.
6262

6363
|'pymode_utils'| Turns off utils
6464

65+
|'pymode_virtualenv'| Turns off virtualenv
66+
6567
|'pymode_utils_whitespaces'| Remove unused whitespaces
6668

6769

@@ -171,6 +173,13 @@ Default: 1.
171173

172174
If this option is set to 0 then utils script is disabled.
173175

176+
------------------------------------------------------------------------------
177+
*'pymode_virtualenv'*
178+
Values: 0 or 1.
179+
Default: 1.
180+
181+
If this option is set to 0 then virtualenv support is disabled.
182+
174183
------------------------------------------------------------------------------
175184
*'pymode_utils_whitespaces'*
176185
Values: 0 or 1.

ftplugin/python/pymode.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ if g:pymode
2020

2121
endif
2222

23+
" Add virtualenv paths
24+
if g:pymode_virtualenv && exists("$VIRTUAL_ENV")
25+
echomsg "Enabled virtualenv: " . $VIRTUAL_ENV
26+
call pymode_virtualenv#Activate()
27+
endif
28+
2329
" Python documentation
2430
if g:pymode_doc
2531

0 commit comments

Comments
 (0)