Skip to content

Commit 14f9008

Browse files
author
Danny Willems (cron)
committed
Merge branch 'develop' of https://github.com/klen/python-mode into develop
2 parents 3f2416e + da4bfe5 commit 14f9008

File tree

9 files changed

+234
-39
lines changed

9 files changed

+234
-39
lines changed

AUTHORS

+12-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Maintainer:
66
Contributors:
77

88
* Alvin Francis (http://github.com/alvinfrancis);
9+
* Andriy Kohut (https://github.com/andriykohut)
910
* Anler Hp (http://github.com/ikame);
1011
* Anton Parkhomenko (http://github.com/chuwy);
1112
* Ashley Hewson (http://github.com/ashleyh);
@@ -27,9 +28,11 @@ Contributors:
2728
* Jonathan McCall (http://github.com/Jonnymcc);
2829
* Kevin Deldycke (http://github.com/kdeldycke);
2930
* Kurtis Rader (https://github.com/krader1961);
31+
* Lawrence Akka (https://github.com/lawrenceakka);
3032
* Lowe Thiderman (http://github.com/thiderman);
3133
* Martin Brochhaus (http://github.com/mbrochh);
3234
* Matthew Moses (http://github.com/mlmoses);
35+
* Maxim (https://github.com/mpyatishev);
3336
* Mel Boyce (http://github.com/syngin);
3437
* Mohammed (http://github.com/mbadran);
3538
* Naoya Inada (http://github.com/naoina);
@@ -45,12 +48,15 @@ Contributors:
4548
* Sorin Ionescu (sorin-ionescu);
4649
* Steve Losh (http://github.com/sjl);
4750
* Tommy Allen (https://github.com/tweekmonster);
51+
* Tony Narlock (https://github.com/tony);
4852
* Tyler Fenby (https://github.com/TFenby);
4953
* Vincent Driessen (https://github.com/nvie);
54+
* Wang Feng (https://github.com/mapler);
5055
* Wayne Ye (https://github.com/WayneYe);
51-
* bendavis78 (http://github.com/bendavis78);
52-
* fwuzju (http://github.com/fwuzju);
53-
* lawrenceakka;
54-
* lee (loyalpartner);
55-
* nixon;
56-
* tramchamploo;
56+
* Wes Turner (https://github.com/westurner);
57+
* bendavis78 (https://github.com/bendavis78);
58+
* fwuzju (https://github.com/fwuzju);
59+
* lee (https://github.com/loyalpartner);
60+
* nixon (https://github.com/nixon);
61+
* sphaugh (https://github.com/sphaugh);
62+
* tramchamploo (https://github.com/tramchamploo);

README.rst

+160-19
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,32 @@
44
.. image:: https://travis-ci.org/klen/python-mode.png?branch=develop
55
:target: https://travis-ci.org/klen/python-mode
66

7-
.. image:: https://dl.dropboxusercontent.com/u/487440/reformal/donate.png
8-
:target: https://www.gittip.com/klen/
9-
:alt: Donate
7+
-----
8+
9+
*The project needs maintainers and contributors*
10+
11+
Actually, I have no time for support the project, so if you feel yourself as
12+
strong don't be hesitate to contact me.
13+
14+
-----
15+
16+
|
17+
| Src: https://github.com/klen/python-mode
18+
| Homepage: https://klen.github.io/python-mode/
19+
| Docs: https://github.com/klen/python-mode/blob/develop/doc/pymode.txt
20+
|
1021
1122
Python-mode is a vim plugin that helps you to create python code very quickly
12-
by utilizing libraries including pylint_, rope_, pydoc_, pyflakes_, pep8_, and
13-
mccabe_ for features like static analysis, refactoring, folding, completion,
23+
by utilizing libraries including
24+
`pylint`_, `rope`_, pydoc_, `pyflakes`_, `pep8`_, `autopep8`_,
25+
`pep257`_ and `mccabe`_
26+
for features like static analysis, refactoring, folding, completion,
1427
documentation, and more.
1528

1629
The plugin contains all you need to develop python applications in Vim.
1730

18-
There is no need to install pylint_, rope_ or any other Python libraries on
19-
your system.
31+
There is no need to install `pylint`_, `rope`_
32+
or any other `Python Libraries`_ on your system.
2033

2134
- Support Python version 2.6+ and 3.2+
2235
- Syntax highlighting
@@ -97,13 +110,13 @@ Then rebuild **helptags** in vim::
97110

98111
Debian packages
99112
---------------
113+
|Repository URL: https://klen.github.io/python-mode/deb/
100114
101-
Repository URL: http://klen.github.io/python-mode/deb/
102115
Install with commands:
103116

104117
::
105118

106-
add-apt-repository http://klen.github.io/python-mode/deb main
119+
add-apt-repository https://klen.github.io/python-mode/deb main
107120
apt-get update
108121
apt-get install vim-python-mode
109122

@@ -176,11 +189,139 @@ https://github.com/klen/python-mode
176189
Please make a pull request to `development` branch and add yourself to
177190
`AUTHORS`.
178191

192+
Source Links
193+
===================
194+
- `doc/pymode.txt
195+
<https://github.com/klen/python-mode/blob/develop/doc/pymode.txt>`__
196+
-- ``:help pymode``
197+
- `plugin/pymode.vim
198+
<https://github.com/klen/python-mode/blob/develop/plugin/pymode.vim>`__
199+
-- python-mode VIM plugin
200+
- `syntax/python.vim
201+
<https://github.com/klen/python-mode/blob/develop/syntax/python.vim>`__
202+
-- python-mode ``python.vim`` VIM syntax
203+
- `syntax/pyrex.vim
204+
<https://github.com/klen/python-mode/blob/develop/syntax/pyrex.vim>`__
205+
-- ``pyrex.vim`` VIM syntax (pyrex, Cython)
206+
- `t/
207+
<https://github.com/klen/python-mode/tree/develop/t>`__
208+
-- ``*.vim`` more python-mode VIM configuration
209+
- `pymode/
210+
<https://github.com/klen/python-mode/tree/develop/pymode>`__
211+
-- ``*.py`` -- python-mode Python module
212+
- `pymode/libs/
213+
<https://github.com/klen/python-mode/tree/develop/pymode/libs>`__
214+
-- ``*.py`` -- `Python Libraries <#python-libraries>`__
215+
216+
217+
Python Libraries
218+
------------------
219+
Vendored Python modules are located
220+
mostly in
221+
`pymode/libs/ <https://github.com/klen/python-mode/tree/develop/pymode/libs>`__.
222+
223+
224+
======
225+
rope
226+
======
227+
| PyPI: https://pypi.python.org/pypi/rope
228+
| Src: https://github.com/python-rope/rope
229+
| Docs: https://github.com/python-rope/rope/blob/master/docs/overview.rst
230+
| Docs: https://github.com/python-rope/rope/blob/master/docs/library.rst
231+
232+
========================
233+
ropemode
234+
========================
235+
| PyPI: https://pypi.python.org/pypi/ropemode
236+
| Src: https://github.com/python-rope/ropemode
237+
238+
=========
239+
ropevim
240+
=========
241+
| PyPI: https://pypi.python.org/pypi/ropevim
242+
| Src: https://github.com/python-rope/ropevim
243+
| Docs: https://github.com/python-rope/ropevim/blob/master/doc/ropevim.txt
244+
245+
=======
246+
pylama
247+
=======
248+
| PyPI: https://pypi.python.org/pypi/pylama
249+
| Src: https://github.com/klen/pylama
250+
251+
========
252+
pylint
253+
========
254+
| PyPI: https://pypi.python.org/pypi/pylint
255+
| Src: https://bitbucket.org/logilab/pylint
256+
| Homepage: http://www.pylint.org/
257+
| Docs: http://docs.pylint.org/
258+
| Docs: http://docs.pylint.org/message-control.html
259+
| Docs: http://docs.pylint.org/faq.html#message-control
260+
| ErrCodes: http://pylint-messages.wikidot.com/all-codes
261+
| ErrCodes: http://pylint-messages.wikidot.com/all-messages
262+
263+
==========
264+
pyflakes
265+
==========
266+
| PyPI: https://pypi.python.org/pypi/pyflakes
267+
| Src: https://github.com/pyflakes/pyflakes
268+
| ErrCodes: https://flake8.readthedocs.org/en/latest/warnings.html
269+
270+
======
271+
pep8
272+
======
273+
| PyPI: https://pypi.python.org/pypi/pep8
274+
| Src: http://github.com/jcrocholl/pep8
275+
| PEP 8: http://www.python.org/dev/peps/pep-0008/
276+
| PEP 8: http://legacy.python.org/dev/peps/pep-0008/
277+
| Docs: https://pep8.readthedocs.org/en/latest/
278+
| Docs: https://pep8.readthedocs.org/en/latest/intro.html#configuration
279+
| ErrCodes: https://pep8.readthedocs.org/en/latest/intro.html#error-codes
280+
281+
=========
282+
autopep8
283+
=========
284+
| PyPI: https://pypi.python.org/pypi/autopep8
285+
| Src: https://github.com/hhatto/autopep8
286+
287+
=======
288+
pep257
289+
=======
290+
| PyPI: https://pypi.python.org/pypi/pep257
291+
| Src: http://github.com/GreenSteam/pep257
292+
| Docs: https://pep257.readthedocs.org/en/latest/
293+
| PEP 257: http://www.python.org/dev/peps/pep-0257/
294+
| ErrCodes: https://pep257.readthedocs.org/en/latest/error_codes.html
295+
296+
=======
297+
mccabe
298+
=======
299+
| PyPI: https://pypi.python.org/pypi/mccabe
300+
| Src: https://github.com/flintwork/mccabe
301+
| Docs: https://en.wikipedia.org/wiki/Cyclomatic_complexity
302+
303+
304+
Vim Libraries
305+
---------------
306+
Vendored Vim modules are located mostly in ``t/``.
307+
308+
======================
309+
Python syntax for vim
310+
======================
311+
| Src: http://www.hlabs.spb.ru/vim/python.vim
312+
313+
314+
=====================
315+
PEP8 VIM indentation
316+
=====================
317+
| Src: http://github.com/hynek/vim-python-pep8-indent
318+
319+
179320

180321
Copyright
181322
=========
182323

183-
Copyright © 2013 Kirill Klenov (klen_)
324+
Copyright © 2013-2015 Kirill Klenov (klen_)
184325

185326
License
186327
=======
@@ -192,17 +333,17 @@ My address is here: "Russia, 143500, MO, Istra, pos. Severny 8-3" to "Kirill Kle
192333
**Thanks for support!**
193334

194335
.. _GNU lesser general public license: http://www.gnu.org/copyleft/lesser.html
195-
.. _klen: http://klen.github.com/
336+
.. _klen: https://klen.github.com/
196337
.. _pydoc: http://docs.python.org/library/pydoc.html
197338
.. _pathogen: https://github.com/tpope/vim-pathogen
198-
.. _rope: https://pypi.python.org/pypi/rope
199-
.. _pylama: https://github.com/klen/pylama
200-
.. _pylint: https://bitbucket.org/logilab/pylint
201-
.. _pyflakes: https://pypi.python.org/pypi/pyflakes
202-
.. _autopep8: https://github.com/hhatto/autopep8
203-
.. _pep257: http://github.com/GreenSteam/pep257
204-
.. _mccabe: https://github.com/flintwork/mccabe
339+
.. _rope_: https://pypi.python.org/pypi/rope
340+
.. _pylama_: https://github.com/klen/pylama
341+
.. _pylint_: https://bitbucket.org/logilab/pylint
342+
.. _pyflakes_: https://pypi.python.org/pypi/pyflakes
343+
.. _autopep8_: https://github.com/hhatto/autopep8
344+
.. _pep257_: http://github.com/GreenSteam/pep257
345+
.. _mccabe_: https://github.com/flintwork/mccabe
205346
.. _pythonvim: http://www.hlabs.spb.ru/vim/python.vim
206-
.. _pep8: http://github.com/jcrocholl/pep8
347+
.. _pep8_: http://github.com/jcrocholl/pep8
207348
.. _pep8indent: http://github.com/hynek/vim-python-pep8-indent
208349
.. |logo| image:: https://raw.github.com/klen/python-mode/develop/logo.png

autoload/pymode.vim

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fun! pymode#quickfix_open(onlyRecognized, maxHeight, minHeight, jumpError) "{{{
5454
redraw
5555
if numOthers > 0
5656
call pymode#wide_message(printf('Quickfix: %d(+%d)', numErrors, numOthers))
57-
else
57+
elseif numErrors > 0
5858
call pymode#wide_message(printf('Quickfix: %d', numErrors))
5959
endif
6060
endfunction "}}}
@@ -128,6 +128,6 @@ endfunction "}}}
128128

129129
fun! pymode#quit() "{{{
130130
augroup pymode
131-
au!
131+
au! * <buffer>
132132
augroup END
133133
endfunction "}}}

doc/pymode.txt

+4
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,10 @@ Highlight "print" as a function *'g:pymode_syntax_print_as_function'*
628628
>
629629
let g:pymode_syntax_print_as_function = 0
630630
631+
Highlight "async/await" keywords *'g:pymode_syntax_highlight_async_await'*
632+
>
633+
let g:pymode_syntax_highlight_async_await = g:pymode_syntax_all
634+
631635
Highlight '=' operator *'g:pymode_syntax_highlight_equal_operator'*
632636
>
633637
let g:pymode_syntax_highlight_equal_operator = g:pymode_syntax_all

pymode/libs3/rope/base/fscommands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def read_str_coding(source):
242242
if not isinstance(source, str):
243243
source = source.decode("utf-8", "ignore")
244244
#TODO: change it to precompiled version
245-
mex = re.search("\-\*\-\s+coding:\s+(.*?)\s+\-\*\-", source)
245+
mex = re.search("\-\*\-\s+coding:\s*(.*?)\s+\-\*\-", source)
246246
if mex:
247247
return mex.group(1)
248248
return "utf-8"

pymode/run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run_code():
6262
errors += [er for er in err.splitlines() if er and "<string>" not in er]
6363

6464
env.let('l:traceback', errors[2:])
65-
env.let('l:output', [s for s in output.split('\n')])
65+
env.let('l:output', [s for s in output.splitlines()])
6666

6767

6868
def __prepare_lines(line1, line2):

pymode/virtualenv.py

+43-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
""" Support virtualenv in pymode. """
22

3-
import os.path
3+
import os
4+
import sys
5+
import site
46

57
from .environment import env
68

@@ -25,13 +27,44 @@ def enable_virtualenv():
2527
activate_this = os.path.join(
2628
os.path.join(path, 'Scripts'), 'activate_this.py')
2729

28-
f = open(activate_this)
2930
try:
30-
source = f.read()
31-
exec(compile( # noqa
32-
source, activate_this, 'exec'), dict(__file__=activate_this))
33-
env.message('Activate virtualenv: ' + path)
34-
env.let('g:pymode_virtualenv_enabled', path)
35-
return True
36-
finally:
37-
f.close()
31+
with open(activate_this) as f:
32+
source = f.read()
33+
exec(compile( # noqa
34+
source, activate_this, 'exec'), dict(__file__=activate_this))
35+
except IOError:
36+
_activate_env_from_path(path)
37+
38+
env.message('Activate virtualenv: ' + path)
39+
env.let('g:pymode_virtualenv_enabled', path)
40+
return True
41+
42+
43+
def _activate_env_from_path(env_path):
44+
""" Fix when `activate_this.py` does not exist.
45+
46+
For Python 3.3 and newer, a new command-line tool `pyvenv` create venv
47+
will not provide 'activate_this.py'.
48+
"""
49+
prev_sys_path = list(sys.path)
50+
51+
if sys.platform == 'win32':
52+
site_packages_paths = [os.path.join(env_path, 'Lib', 'site-packages')]
53+
else:
54+
lib_path = os.path.join(env_path, 'lib')
55+
site_packages_paths = [os.path.join(lib_path, lib, 'site-packages')
56+
for lib in os.listdir(lib_path)]
57+
for site_packages_path in site_packages_paths:
58+
site.addsitedir(site_packages_path)
59+
60+
sys.real_prefix = sys.prefix
61+
sys.prefix = env_path
62+
sys.exec_prefix = env_path
63+
64+
# Move the added items to the front of the path:
65+
new_sys_path = []
66+
for item in list(sys.path):
67+
if item not in prev_sys_path:
68+
new_sys_path.append(item)
69+
sys.path.remove(item)
70+
sys.path[:0] = new_sys_path

syntax/python.vim

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ call pymode#default('g:pymode_syntax_all', 1)
1616

1717
" Highlight 'print' as function
1818
call pymode#default("g:pymode_syntax_print_as_function", 0)
19+
"
20+
" Highlight 'async/await' keywords
21+
call pymode#default("g:pymode_syntax_highlight_async_await", g:pymode_syntax_all)
1922

2023
" Highlight '=' operator
2124
call pymode#default('g:pymode_syntax_highlight_equal_operator', g:pymode_syntax_all)
@@ -101,6 +104,13 @@ endif
101104
syn keyword pythonStatement print
102105
endif
103106

107+
if g:pymode_syntax_highlight_async_await
108+
syn keyword pythonStatement async await
109+
syn match pythonStatement "\<async\s\+def\>" nextgroup=pythonFunction skipwhite
110+
syn match pythonStatement "\<async\s\+with\>" display
111+
syn match pythonStatement "\<async\s\+for\>" nextgroup=pythonRepeat skipwhite
112+
endif
113+
104114
if g:pymode_syntax_highlight_equal_operator
105115
syn match pythonExtraOperator "\%(=\)"
106116
endif

0 commit comments

Comments
 (0)