Skip to content

Commit bd6caec

Browse files
committed
Merge git://github.com/klen/python-mode
Conflicts: syntax/python.vim
2 parents b6c1220 + cd6aec2 commit bd6caec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+7709
-3109
lines changed

Changelog.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
11
Changelog
22
=========
33

4+
## 2012-09-07 0.6.10
5+
--------------------
6+
* Dont raise an exception when Logger has no message handler (c) nixon
7+
* Improve performance of white space removal (c) Dave Smith
8+
* Improve ropemode support (c) s0undt3ch
9+
* Add `g:pymode_updatetime` option
10+
* Update autopep8 to version 0.8.1
11+
12+
## 2012-09-07 0.6.9
13+
-------------------
14+
* Update autopep8
15+
* Improve pymode#troubleshooting#Test()
16+
17+
## 2012-09-06 0.6.8
18+
-------------------
19+
* Add PEP8 indentation ":help 'pymode_indent'"
20+
21+
## 2012-08-15 0.6.7
22+
-------------------
23+
* Fix documentation. Thanks (c) bgrant;
24+
* Fix pymode "async queue" support.
25+
26+
## 2012-08-02 0.6.6
27+
-------------------
28+
* Updated Pep8 to version 1.3.3
29+
* Updated Pylint to version 0.25.2
30+
* Fixed virtualenv support for windows users
31+
* Added pymode modeline ':help PythonModeModeline'
32+
* Added diagnostic tool ':call pymode#troubleshooting#Test()'
33+
* Added `PyLintAuto` command ':help PyLintAuto'
34+
* Code checking is async operation now
35+
* More, more fast the pymode folding
36+
* Repaired execution of python code
37+
438
## 2012-05-24 0.6.4
539
-------------------
640
* Add 'pymode_paths' option

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.PHONY: clean
2+
clean:
3+
find . -name "*.pyc" -delete

README.rst

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ See (very old) screencast here: http://t.co/3b0bzeXA (sorry for quality, this is
3030
Changelog
3131
=========
3232

33-
## 2012-04-10 0.6.2
33+
## 2012-08-02 0.6.5
3434
-------------------
35-
* Fix pymode_run for "unnamed" clipboard
36-
* Add 'pymode_lint_mccabe_complexity' option
37-
* Update Pep8 to version 1.0.1
38-
* Warning! Change 'pymode_rope_goto_def_newwin' option
39-
for open "goto definition" in new window, set it to 'new' or 'vnew'
40-
for horizontally or vertically split
41-
If you use default behaviour (in the same buffer), not changes needed.
35+
* Updated Pep8 to version 1.3.3
36+
* Updated Pylint to version 0.25.2
37+
* Fixed virtualenv support for windows users
38+
* Added pymode modeline ':help PythonModeModeline'
39+
* Added diagnostic tool ':call pymode#troubleshooting#Test()'
40+
* Added `PyLintAuto` command ':help PyLintAuto'
41+
* Code checking is async operation now
42+
* More, more fast the pymode folding
43+
* Repaired execution of python code
4244

4345

4446
Requirements
@@ -90,6 +92,16 @@ Then rebuild **helptags** in vim::
9092
must be enabled for use python-mode.
9193

9294

95+
Troubleshooting
96+
===============
97+
98+
If your python-mode dont work, type command: ::
99+
100+
:call pymode#troubleshooting#Test()
101+
102+
And fix warnings or copy output and send it to me (ex. with github issue).
103+
104+
93105
Settings
94106
========
95107

@@ -275,11 +287,11 @@ Default values: ::
275287
" Autoremove unused whitespaces
276288
let g:pymode_utils_whitespaces = 1
277289

278-
" Set default pymode python indent options
279-
let g:pymode_options_indent = 1
290+
" Enable pymode indentation
291+
let g:pymode_indent = 1
280292

281-
" Set default pymode python other options
282-
let g:pymode_options_other = 1
293+
" Set default pymode python options
294+
let g:pymode_options = 1
283295

284296

285297
Syntax highlight
@@ -385,6 +397,8 @@ PyLintCheckerToggle Toggle code checker (pylint, pyflakes)
385397
-------------------- -------------
386398
PyLint Check current buffer
387399
-------------------- -------------
400+
PyLintAuto Automatic fix PEP8 errors
401+
-------------------- -------------
388402
Pyrun Run current buffer in python
389403
==================== =============
390404

@@ -419,6 +433,20 @@ Try use pyflakes_, see ``:h 'pymode_lint_checker'``.
419433
Example: On Flask projects I automaticly set ``g:pymode_lint_checker = "pyflakes"``, on django ``g:pymode_lint_cheker = "pylint"``
420434

421435

436+
OSX cannot import urandom
437+
-------------------------
438+
439+
See: https://groups.google.com/forum/?fromgroups=#!topic/vim_dev/2NXKF6kDONo
440+
441+
The sequence of commands that fixed this: ::
442+
443+
brew unlink python
444+
brew unlink macvim
445+
brew remove macvim
446+
brew install -v --force macvim
447+
brew link macvim
448+
brew link python
449+
422450

423451
Bugtracker
424452
===========
@@ -456,10 +484,18 @@ Copyright (C) 2012 Kirill Klenov (klen_)
456484
Copyright (C) 2006 Johann C. Rocholl <[email protected]>
457485
http://github.com/jcrocholl/pep8
458486

487+
**autopep8**:
488+
Copyright (c) 2012 hhatto <[email protected]>
489+
https://github.com/hhatto/autopep8
490+
459491
**Python syntax for vim**
460492
Copyright (c) 2010 Dmitry Vasiliev
461493
http://www.hlabs.spb.ru/vim/python.vim
462494

495+
**PEP8 VIM indentation**
496+
Copyright (c) 2012 Hynek Schlawack <[email protected]>
497+
http://github.com/hynek/vim-python-pep8-indent
498+
463499

464500
License
465501
=======

after/indent/python.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
if pymode#Default('b:pymode_indent', 1) || !g:pymode_indent
2+
finish
3+
endif
4+
5+
6+
setlocal nolisp
7+
setlocal tabstop=4
8+
setlocal softtabstop=4
9+
setlocal shiftwidth=4
10+
setlocal shiftround
11+
setlocal expandtab
12+
setlocal autoindent
13+
setlocal indentexpr=pymode#indent#Indent(v:lnum)
14+
setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except

autoload/pymode.vim

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ fun! pymode#Default(name, default) "{{{
1212
endfunction "}}}
1313

1414

15+
fun! pymode#Option(name) "{{{
16+
17+
let name = 'b:pymode_' . a:name
18+
if exists(name)
19+
return eval(name)
20+
endif
21+
22+
let name = 'g:pymode_' . a:name
23+
return eval(name)
24+
25+
endfunction "}}}
26+
27+
1528
fun! pymode#QuickfixOpen(onlyRecognized, holdCursor, maxHeight, minHeight, jumpError) "{{{
1629
" DESC: Open quickfix window
1730
"
@@ -22,7 +35,7 @@ fun! pymode#QuickfixOpen(onlyRecognized, holdCursor, maxHeight, minHeight, jumpE
2235
exe max([min([line("$"), a:maxHeight]), a:minHeight]) . "wincmd _"
2336
if a:jumpError
2437
cc
25-
elseif a:holdCursor
38+
elseif !a:holdCursor
2639
wincmd p
2740
endif
2841
else
@@ -42,9 +55,15 @@ fun! pymode#PlaceSigns() "{{{
4255
"
4356
if has('signs')
4457
sign unplace *
58+
59+
if !pymode#Default("g:pymode_lint_signs_always_visible", 0) || g:pymode_lint_signs_always_visible
60+
call RopeShowSignsRulerIfNeeded()
61+
endif
62+
4563
for item in filter(getqflist(), 'v:val.bufnr != ""')
4664
execute printf('silent! sign place 1 line=%d name=%s buffer=%d', item.lnum, item.type, item.bufnr)
4765
endfor
66+
4867
endif
4968
endfunction "}}}
5069

@@ -106,7 +125,7 @@ fun! pymode#WideMessage(msg) "{{{
106125
let x=&ruler | let y=&showcmd
107126
set noruler noshowcmd
108127
redraw
109-
echo strpart(a:msg, 0, &columns-1)
128+
echohl Debug | echo strpart(a:msg, 0, &columns-1) | echohl none
110129
let &ruler=x | let &showcmd=y
111130
endfunction "}}}
112131

@@ -149,4 +168,23 @@ fun! pymode#BlockEnd(lnum, ...) "{{{
149168
endfunction "}}}
150169

151170

171+
fun! pymode#Modeline() "{{{
172+
let modeline = getline(prevnonblank('$'))
173+
if modeline =~ '^#\s\+pymode:'
174+
for ex in split(modeline, ':')[1:]
175+
let [name, value] = split(ex, '=')
176+
let {'b:pymode_'.name} = value
177+
endfor
178+
endif
179+
au BufRead <buffer> call pymode#Modeline()
180+
endfunction "}}}
181+
182+
183+
fun! pymode#TrimWhiteSpace() "{{{
184+
let cursor_pos = getpos('.')
185+
silent! %s/\s\+$//
186+
call setpos('.', cursor_pos)
187+
endfunction "}}}
188+
189+
152190
" vim: fdm=marker:fdl=0

autoload/pymode/breakpoint.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@ fun! pymode#breakpoint#Set(lnum) "{{{
77
call append(line('.')-1, repeat(' ', indent(plnum)).g:pymode_breakpoint_cmd)
88
normal k
99
endif
10+
11+
" Disable lint
12+
let pymode_lint = g:pymode_lint
13+
let g:pymode_lint = 0
14+
15+
" Save file
1016
if &modifiable && &modified | write | endif
17+
18+
let g:pymode_lint = pymode_lint
19+
1120
endfunction "}}}

autoload/pymode/folding.vim

Lines changed: 19 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
" Python-mode folding functions
22

33

4-
let s:defpat = '^\s*\(@\|class\s.*:\|def\s\)'
4+
let s:blank_regex = '^\s*$'
5+
let s:def_regex = '^\s*\(class\|def\) \w\+'
56

67

78
fun! pymode#folding#text() " {{{
@@ -25,81 +26,34 @@ fun! pymode#folding#text() " {{{
2526
endfunction "}}}
2627

2728

28-
fun! pymode#folding#indent(lnum) "{{{
29-
let indent = indent(pymode#BlockStart(a:lnum))
30-
return indent ? indent + &shiftwidth : 0
31-
endfunction "}}}
32-
33-
3429
fun! pymode#folding#expr(lnum) "{{{
30+
3531
let line = getline(a:lnum)
3632
let indent = indent(a:lnum)
3733

38-
if line == ''
39-
return getline(a:lnum+1) == '' ? '=' : '-1'
40-
endif
41-
42-
if line =~ s:defpat && getline(prevnonblank(a:lnum-1)) !~ '^\s*@'
43-
let n = a:lnum
44-
while getline(n) =~ '^\s*@'
45-
let n = nextnonblank(n + 1)
46-
endwhile
47-
if getline(n) =~ s:defpat
48-
return ">".(indent/&shiftwidth+1)
49-
endif
34+
if line =~ s:def_regex
35+
return ">".(indent / &shiftwidth + 1)
5036
endif
5137

52-
let p = prevnonblank(a:lnum-1)
53-
while p>0 && getline(p) =~ '^\s*#'
54-
let p = prevnonblank(p-1)
55-
endwhile
56-
let pind = indent(p)
57-
if getline(p) =~ s:defpat && getline(prevnonblank(a:lnum - 1)) !~ '^\s*@'
58-
let pind = pind + &shiftwidth
59-
elseif p==0
60-
let pind = 0
38+
if line =~ '^\s*@'
39+
return -1
6140
endif
6241

63-
if (indent>0 && indent==pind) || indent>pind
64-
return '='
65-
elseif indent==0
66-
if pind==0 && line =~ '^#'
67-
return 0
68-
elseif line !~'^#'
69-
if 0<pind && line!~'^else\s*:\|^except.*:\|^elif.*:\|^finally\s*:'
70-
return '>1'
71-
elseif 0==pind && getline(prevnonblank(a:lnum-1)) =~ '^\s*#'
72-
return '>1'
73-
else
74-
return '='
75-
endif
76-
endif
77-
let n = nextnonblank(a:lnum+1)
78-
while n>0 && getline(n) =~'^\s*#'
79-
let n = nextnonblank(n+1)
80-
endwhile
81-
if indent(n)==0
82-
return 0
83-
else
42+
if line =~ s:blank_regex
43+
let prev_line = getline(a:lnum - 1)
44+
if prev_line =~ s:blank_regex
8445
return -1
85-
end
86-
endif
87-
let blockindent = indent(pymode#BlockStart(a:lnum)) + &shiftwidth
88-
if blockindent==0
89-
return 1
46+
else
47+
return foldlevel(prevnonblank(a:lnum))
48+
endif
9049
endif
91-
let n = nextnonblank(a:lnum+1)
92-
while n>0 && getline(n) =~'^\s*#'
93-
let n = nextnonblank(n+1)
94-
endwhile
95-
let nind = indent(n)
96-
if line =~ '^\s*#' && indent>=nind
97-
return -1
98-
elseif line =~ '^\s*#'
99-
return nind / &shiftwidth
100-
else
101-
return blockindent / &shiftwidth
50+
51+
if indent == 0
52+
return 0
10253
endif
54+
55+
return '='
56+
10357
endfunction "}}}
10458

10559

0 commit comments

Comments
 (0)