Skip to content

Commit b6c1220

Browse files
committed
Merge git://github.com/klen/python-mode
Conflicts: syntax/python.vim
2 parents 044d358 + 9f976bb commit b6c1220

25 files changed

+387
-258
lines changed

Changelog.rst

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

4+
## 2012-05-24 0.6.4
5+
-------------------
6+
* Add 'pymode_paths' option
7+
* Rope updated to version 0.9.4
8+
9+
## 2012-04-18 0.6.3
10+
-------------------
11+
* Fix pydocs integration
12+
13+
## 2012-04-10 0.6.2
14+
-------------------
15+
* Fix pymode_run for "unnamed" clipboard
16+
* Add 'pymode_lint_mccabe_complexity' option
17+
* Update Pep8 to version 1.0.1
18+
* Warning! Change 'pymode_rope_goto_def_newwin' option
19+
for open "goto definition" in new window, set it to 'new' or 'vnew'
20+
for horizontally or vertically split
21+
If you use default behaviour (in the same buffer), not changes needed.
22+
423
## 2012-03-13 0.6.0
524
-------------------
625
* Add 'pymode_lint_hold' option

README.rst

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

33-
## 2012-02-12 0.5.8
33+
## 2012-04-10 0.6.2
3434
-------------------
35-
* Fix pylint for Windows users
36-
* Python documentation search running from Vim (delete g:pydoc option)
37-
* Python code execution running from Vim (delete g:python option)
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.
3842

3943

4044
Requirements
@@ -74,7 +78,7 @@ Manually
7478
::
7579

7680
% git clone git://github.com/klen/python-mode.git
77-
% cd python-mode.vim
81+
% cd python-mode
7882
% cp -R * ~/.vim
7983

8084
Then rebuild **helptags** in vim::
@@ -170,6 +174,9 @@ Default values: ::
170174
" Place error signs
171175
let g:pymode_lint_signs = 1
172176

177+
" Maximum allowed mccabe complexity
178+
let g:pymode_lint_mccabe_complexity = 8
179+
173180
" Minimal height of pylint error window
174181
let g:pymode_lint_minheight = 3
175182

@@ -219,7 +226,7 @@ Default values: ::
219226

220227
let g:pymode_rope_guess_project = 1
221228

222-
let g:pymode_rope_goto_def_newwin = 0
229+
let g:pymode_rope_goto_def_newwin = ""
223230

224231
let g:pymode_rope_always_show_complete_menu = 0
225232

@@ -256,6 +263,9 @@ Other stuff
256263

257264
Default values: ::
258265

266+
" Additional python paths
267+
let g:pymode_paths = []
268+
259269
" Load breakpoints plugin
260270
let g:pymode_breakpoint = 1
261271

@@ -442,6 +452,10 @@ Copyright (C) 2012 Kirill Klenov (klen_)
442452
Copyright (c) 2005 Divmod, Inc.
443453
http://www.divmod.com/
444454

455+
**PEP8**
456+
Copyright (C) 2006 Johann C. Rocholl <johann@rocholl.net>
457+
http://github.com/jcrocholl/pep8
458+
445459
**Python syntax for vim**
446460
Copyright (c) 2010 Dmitry Vasiliev
447461
http://www.hlabs.spb.ru/vim/python.vim

autoload/pymode.vim

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ endfunction "}}}
4040
fun! pymode#PlaceSigns() "{{{
4141
" DESC: Place error signs
4242
"
43-
sign unplace *
44-
for item in filter(getqflist(), 'v:val.bufnr != ""')
45-
execute printf('silent! sign place 1 line=%d name=%s buffer=%d', item.lnum, item.type, item.bufnr)
46-
endfor
43+
if has('signs')
44+
sign unplace *
45+
for item in filter(getqflist(), 'v:val.bufnr != ""')
46+
execute printf('silent! sign place 1 line=%d name=%s buffer=%d', item.lnum, item.type, item.bufnr)
47+
endfor
48+
endif
4749
endfunction "}}}
4850

4951

@@ -74,10 +76,11 @@ endfunction "}}}
7476
fun! pymode#ShowStr(str) "{{{
7577
" DESC: Open temp buffer with `str`.
7678
"
79+
let g:pymode_curbuf = bufnr("%")
7780
call pymode#TempBuffer()
7881
put! =a:str
82+
wincmd p
7983
redraw
80-
normal gg | wincmd p
8184
endfunction "}}}
8285

8386

@@ -92,7 +95,8 @@ fun! pymode#ShowCommand(cmd) "{{{
9295
echoerr 'Command fail: '.a:cmd
9396
endtry
9497
redraw
95-
normal gg | wincmd p
98+
normal gg
99+
wincmd p
96100
endfunction "}}}
97101

98102

autoload/pymode/doc.vim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ fun! pymode#doc#Show(word) "{{{
55
if a:word == ''
66
echoerr "No name/symbol under cursor!"
77
else
8+
py import StringIO
89
py sys.stdout, _ = StringIO.StringIO(), sys.stdout
910
py help(vim.eval('a:word'))
1011
py sys.stdout, out = _, sys.stdout.getvalue()
11-
redi @">
12-
sil!py print out
13-
redi END
1412
call pymode#TempBuffer()
15-
normal Pdd
13+
py vim.current.buffer.append(out.split('\n'), 0)
1614
wincmd p
1715
endif
1816
endfunction "}}}

autoload/pymode/folding.vim

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,50 +35,70 @@ fun! pymode#folding#expr(lnum) "{{{
3535
let line = getline(a:lnum)
3636
let indent = indent(a:lnum)
3737

38-
if line == '' | return getline(a:lnum+1) == ''?'=':'-1' | endif
38+
if line == ''
39+
return getline(a:lnum+1) == '' ? '=' : '-1'
40+
endif
3941

4042
if line =~ s:defpat && getline(prevnonblank(a:lnum-1)) !~ '^\s*@'
4143
let n = a:lnum
42-
while getline(n) =~ '^\s*@' | let n = nextnonblank(n + 1) | endwhile
44+
while getline(n) =~ '^\s*@'
45+
let n = nextnonblank(n + 1)
46+
endwhile
4347
if getline(n) =~ s:defpat
4448
return ">".(indent/&shiftwidth+1)
4549
endif
4650
endif
4751

4852
let p = prevnonblank(a:lnum-1)
49-
while p>0 && getline(p) =~ '^\s*#' | let p = prevnonblank(p-1)
53+
while p>0 && getline(p) =~ '^\s*#'
54+
let p = prevnonblank(p-1)
5055
endwhile
5156
let pind = indent(p)
5257
if getline(p) =~ s:defpat && getline(prevnonblank(a:lnum - 1)) !~ '^\s*@'
5358
let pind = pind + &shiftwidth
54-
elseif p==0 | let pind = 0
59+
elseif p==0
60+
let pind = 0
5561
endif
5662

57-
if indent>0 && indent==pind | return '='
58-
elseif indent>pind | return '='
63+
if (indent>0 && indent==pind) || indent>pind
64+
return '='
5965
elseif indent==0
60-
if pind==0 && line =~ '^#' | return 0
66+
if pind==0 && line =~ '^#'
67+
return 0
6168
elseif line !~'^#'
62-
if 0<pind && line!~'^else\s*:\|^except.*:\|^elif.*:\|^finally\s*:' | return '>1'
63-
elseif 0==pind && getline(prevnonblank(a:lnum-1)) =~ '^\s*#' | return '>1'
64-
else | return '='
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 '='
6575
endif
6676
endif
6777
let n = nextnonblank(a:lnum+1)
68-
while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1)
78+
while n>0 && getline(n) =~'^\s*#'
79+
let n = nextnonblank(n+1)
6980
endwhile
70-
if indent(n)==0 | return 0
71-
else | return -1
81+
if indent(n)==0
82+
return 0
83+
else
84+
return -1
7285
end
7386
endif
7487
let blockindent = indent(pymode#BlockStart(a:lnum)) + &shiftwidth
75-
if blockindent==0 | return 1 | endif
88+
if blockindent==0
89+
return 1
90+
endif
7691
let n = nextnonblank(a:lnum+1)
77-
while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1) | endwhile
92+
while n>0 && getline(n) =~'^\s*#'
93+
let n = nextnonblank(n+1)
94+
endwhile
7895
let nind = indent(n)
79-
if line =~ '^\s*#' && indent>=nind | return -1
80-
elseif line =~ '^\s*#' | return nind / &shiftwidth
81-
else | return blockindent / &shiftwidth
96+
if line =~ '^\s*#' && indent>=nind
97+
return -1
98+
elseif line =~ '^\s*#'
99+
return nind / &shiftwidth
100+
else
101+
return blockindent / &shiftwidth
82102
endif
83103
endfunction "}}}
84104

autoload/pymode/run.vim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
" DESC: Save file if it modified and run python code
22
fun! pymode#run#Run(line1, line2) "{{{
33
if &modifiable && &modified | write | endif
4-
redi @">
5-
sil!py execfile(vim.eval('expand("%s:p")'))
6-
redi END
4+
py import StringIO
5+
py sys.stdout, _ = StringIO.StringIO(), sys.stdout
6+
py execfile(vim.eval('expand("%s:p")'), {}, {})
7+
py sys.stdout, out = _, sys.stdout.getvalue()
78
call pymode#TempBuffer()
8-
normal Pdd
9+
py vim.current.buffer.append(out.split('\n'), 0)
910
wincmd p
1011
endfunction "}}}

autoload/pymode/virtualenv.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ fun! pymode#virtualenv#Activate() "{{{
1313
call add(g:pymode_virtualenv_enabled, $VIRTUAL_ENV)
1414

1515
python << EOF
16+
import sys, vim, os
17+
1618
ve_dir = os.environ['VIRTUAL_ENV']
1719
ve_dir in sys.path or sys.path.insert(0, ve_dir)
1820
activate_this = os.path.join(os.path.join(ve_dir, 'bin'), 'activate_this.py')

doc/pymode.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(__) (__) (__) (_) (_)(_____)(_)\_) (_/\/\_)(_____)(____/(____) ~
77

88

9-
Version: 0.6.0
9+
Version: 0.6.4
1010

1111
==============================================================================
1212
CONTENTS *Python-mode-contents*
@@ -43,6 +43,8 @@ to install the pylint or rope library on your system.
4343
The script provides the following options that can customise the behaviour the
4444
PythonMode. These options should be set in your vimrc.
4545

46+
|'pymode_paths'| Additional python paths for pymode
47+
4648
|'pymode_doc'| Turns off the documentation script
4749

4850
|'pymode_doc_key'| Key for show documentation
@@ -77,6 +79,8 @@ PythonMode. These options should be set in your vimrc.
7779

7880
|'pymode_lint_minheight'| Minimal height of pylint error window
7981

82+
|'pymode_lint_mccabe_complexity'| Maximum allowed mccabe complexity
83+
8084
|'pymode_lint_maxheight'| Maximal height of pylint error window
8185

8286
|'pymode_rope'| Turns off rope script
@@ -114,6 +118,13 @@ PythonMode. These options should be set in your vimrc.
114118
To enable any of the below options you should put the given line in your
115119
'$HOME/.vimrc'. See |vimrc-intro|.
116120

121+
------------------------------------------------------------------------------
122+
*'pymode_paths'*
123+
Values: List of strings
124+
Default: [].
125+
126+
This option set additional python import paths
127+
117128
------------------------------------------------------------------------------
118129
*'pymode_doc'*
119130
Values: 0 or 1.
@@ -243,6 +254,13 @@ Default: 3.
243254

244255
Set minimal height for pylint cwindow
245256

257+
------------------------------------------------------------------------------
258+
*'pymode_lint_mccabe_complexity'*
259+
Values: int
260+
Default: 8.
261+
262+
Set minimal complexity for mccabe linter.
263+
246264
------------------------------------------------------------------------------
247265
*'pymode_lint_maxheight'*
248266
Values: int
@@ -457,6 +475,10 @@ You may set |exrc| and |secure| in your |vimrc| for auto set custom settings fro
457475
Copyright (c) 2005 Divmod, Inc.
458476
http://www.divmod.com/
459477

478+
PEP8:
479+
Copyright (C) 2006 Johann C. Rocholl <johann@rocholl.net>
480+
http://github.com/jcrocholl/pep8
481+
460482
Python syntax for vim:
461483
Copyright (c) 2010 Dmitry Vasiliev
462484
http://www.hlabs.spb.ru/vim/python.vim

doc/ropevim.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ restructuring can be: >
252252
for "go to definition" result if the definition
253253
found is located in another file. By default the
254254
file is open in the same buffer.
255+
Values: '' -- same buffer, 'new' --
256+
horizontally split, 'vnew' --
257+
vertically split
255258

256259
*'pymode_rope_always_show_complete_menu'* If set, rope autocompletion menu
257260
always show.

ftplugin/python/pymode.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ endif
2828
if !pymode#Default('g:pymode_options_other', 1) || g:pymode_options_other
2929
setlocal complete+=t
3030
setlocal formatoptions-=t
31-
setlocal number
31+
if v:version > 702 && !&relativenumber
32+
setlocal number
33+
endif
3234
setlocal nowrap
33-
setlocal textwidth=80
35+
setlocal textwidth=79
3436
endif
3537

3638
" }}}
@@ -45,7 +47,7 @@ if g:pymode_doc
4547

4648
" DESC: Set keys
4749
exe "nnoremap <silent> <buffer> " g:pymode_doc_key ":call pymode#doc#Show(expand('<cword>'))<CR>"
48-
exe "vnoremap <silent> <buffer> " g:pymode_doc_key ":call pymode#doc#Show('<C-R><C-A>')<CR>"
50+
exe "vnoremap <silent> <buffer> " g:pymode_doc_key ":<C-U>call pymode#doc#Show(@*)<CR>"
4951

5052
endif
5153

0 commit comments

Comments
 (0)