Skip to content

Commit ad60c23

Browse files
committed
Merge branch 'master' of git://github.com/klen/python-mode
2 parents 5231a90 + 6cf0c64 commit ad60c23

File tree

13 files changed

+325
-129
lines changed

13 files changed

+325
-129
lines changed

Changelog.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
Changelog
22
=========
33

4-
## 2012-02-?? 0.6.0
4+
## 2012-03-13 0.6.0
55
-------------------
66
* Add 'pymode_lint_hold' option
77
* Improve pymode loading speed
88
* Add pep8, mccabe lint checkers
99
* Now g:pymode_lint_checker can have many values
1010
Ex. "pep8,pyflakes,mccabe"
1111
* Add 'pymode_lint_ignore' and 'pymode_lint_select' options
12+
* Fix rope keys
13+
* Fix python motion in visual mode
14+
* Add folding 'pymode_folding'
15+
* Warning: 'pymode_lint_checker' now set to 'pyflakes,pep8,mccabe' by default
1216

1317
## 2012-02-12 0.5.8
1418
-------------------

README.rst

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ This plugin allow you create python code in vim very easily.
88
There is no need to install the pylint_, rope_ or any used python library on your system.
99

1010
- Python objects and motion (]], 3[[, ]]M, vaC, viM, daC, ciM, ...)
11+
- Folding of python code
12+
- Virtualenv support
1113
- Highlight syntax errors
1214
- Highlight and auto fix unused imports
15+
- Many linters (pylint_, pyflakes_, ...) that can be run simultaneously
1316
- Strong code completion
1417
- Code refactoring
1518
- Python documentation
1619
- Run python code
1720
- Go to definition
1821
- Powerful customization
19-
- Virtualenv support
20-
- Many linters (pylint_, pyflakes_, ...) that can be run simultaneously
21-
- And more...
22+
- And more, more ...
2223

23-
See (old) screencast here: http://t.co/3b0bzeXA (sorry for quality, this is my first screencast)
24+
See (very old) screencast here: http://t.co/3b0bzeXA (sorry for quality, this is my first screencast)
2425

2526

2627
.. contents::
@@ -133,7 +134,7 @@ Default values: ::
133134

134135
" Switch pylint, pyflakes, pep8, mccabe code-checkers
135136
" Can have multiply values "pep8,pyflakes,mcccabe"
136-
let g:pymode_lint_checker = "pylint"
137+
let g:pymode_lint_checker = "pyflakes,pep8,mccabe"
137138

138139
" Skip errors and warnings
139140
" E.g. "E501,W002", "E2,W" (Skip all Warnings and Errors startswith E2) and etc
@@ -223,14 +224,38 @@ Default values: ::
223224
let g:pymode_rope_always_show_complete_menu = 0
224225

225226

226-
Other stuff
227-
-----------
227+
Automatically folding of python code
228+
--------------------------------------
229+
230+
Default values: ::
231+
232+
" Enable python folding
233+
let g:pymode_folding = 1
234+
235+
236+
Vim python motions and operators
237+
--------------------------------
228238

229239
Default values: ::
230240

231-
" Load python objects and motion
241+
" Enable python objects and motion
232242
let g:pymode_motion = 1
233243

244+
245+
Virtualenv support
246+
------------------
247+
248+
Default values: ::
249+
250+
" Auto fix vim python paths if virtualenv enabled
251+
let g:pymode_virtualenv = 1
252+
253+
254+
Other stuff
255+
-----------
256+
257+
Default values: ::
258+
234259
" Load breakpoints plugin
235260
let g:pymode_breakpoint = 1
236261

@@ -240,15 +265,9 @@ Default values: ::
240265
" Autoremove unused whitespaces
241266
let g:pymode_utils_whitespaces = 1
242267

243-
" Auto fix vim python paths if virtualenv enabled
244-
let g:pymode_virtualenv = 1
245-
246268
" Set default pymode python indent options
247269
let g:pymode_options_indent = 1
248270

249-
" Set default pymode python fold options
250-
let g:pymode_options_fold = 1
251-
252271
" Set default pymode python other options
253272
let g:pymode_options_other = 1
254273

@@ -310,6 +329,12 @@ Keys Command
310329
-------------- -------------
311330
**<C-Space>** Rope autocomplete (g:pymode_rope enabled)
312331
-------------- -------------
332+
**<C-c>g** Rope goto definition (g:pymode_rope enabled)
333+
-------------- -------------
334+
**<C-c>d** Rope show documentation (g:pymode_rope enabled)
335+
-------------- -------------
336+
**<C-c>f** Rope find occurrences (g:pymode_rope enabled)
337+
-------------- -------------
313338
**<Leader>r** Run python (g:pymode_run enabled)
314339
-------------- -------------
315340
**<Leader>b** Set, unset breakpoint (g:pymode_breakpoint enabled)
@@ -402,7 +427,7 @@ Development of pylint-mode happens at github: https://github.com/klen/python-mod
402427
Copyright
403428
=========
404429

405-
Copyright (C) 2011 Kirill Klenov (klen_)
430+
Copyright (C) 2012 Kirill Klenov (klen_)
406431

407432
**Rope**
408433
Copyright (C) 2006-2010 Ali Gholami Rudi

after/ftplugin/python.vim

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ endif
77

88
if !pymode#Default('g:pymode_motion', 1) || g:pymode_motion
99

10-
nnoremap <buffer> ]] :<C-U>call pymode#motion#move2('^\(class\\|def\)\s', '')<CR>
11-
nnoremap <buffer> [[ :<C-U>call pymode#motion#move2('^\(class\\|def\)\s', 'b')<CR>
12-
nnoremap <buffer> ]C :<C-U>call pymode#motion#move2('^\(class\\|def\)\s', '')<CR>
13-
nnoremap <buffer> [C :<C-U>call pymode#motion#move2('^\(class\\|def\)\s', 'b')<CR>
14-
nnoremap <buffer> ]M :<C-U>call pymode#motion#move2('^\s*def\s', '')<CR>
15-
nnoremap <buffer> [M :<C-U>call pymode#motion#move2('^\s*def\s', 'b')<CR>
16-
17-
onoremap <buffer> ]] :<C-U>call pymode#motion#move2('^\(class\\|def\)\s', '')<CR>
18-
onoremap <buffer> [[ :<C-U>call pymode#motion#move2('^\(class\\|def\)\s', 'b')<CR>
19-
onoremap <buffer> ]C :<C-U>call pymode#motion#move2('^\(class\\|def\)\s', '')<CR>
20-
onoremap <buffer> [C :<C-U>call pymode#motion#move2('^\(class\\|def\)\s', 'b')<CR>
21-
onoremap <buffer> ]M :<C-U>call pymode#motion#move2('^\s*def\s', '')<CR>
22-
onoremap <buffer> [M :<C-U>call pymode#motion#move2('^\s*def\s', 'b')<CR>
23-
24-
vnoremap <buffer> ]] :<C-U>call pymode#motion#vmove('^\(class\\|def\)\s', '')<CR>
25-
vnoremap <buffer> [[ :<C-U>call pymode#motion#vmove('^\(class\\|def\)\s', 'b')<CR>
26-
vnoremap <buffer> ]M :<C-U>call pymode#motion#vmove('^\s*def\s', '')<CR>
27-
vnoremap <buffer> [M :<C-U>call pymode#motion#vmove('^\s*def\s', 'b')<CR>
10+
nnoremap <buffer> ]] :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
11+
nnoremap <buffer> [[ :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
12+
nnoremap <buffer> ]C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
13+
nnoremap <buffer> [C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
14+
nnoremap <buffer> ]M :<C-U>call pymode#motion#move('^\s*def\s', '')<CR>
15+
nnoremap <buffer> [M :<C-U>call pymode#motion#move('^\s*def\s', 'b')<CR>
16+
17+
onoremap <buffer> ]] :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
18+
onoremap <buffer> [[ :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
19+
onoremap <buffer> ]C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
20+
onoremap <buffer> [C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
21+
onoremap <buffer> ]M :<C-U>call pymode#motion#move('^\s*def\s', '')<CR>
22+
onoremap <buffer> [M :<C-U>call pymode#motion#move('^\s*def\s', 'b')<CR>
23+
24+
vnoremap <buffer> ]] :call pymode#motion#vmove('^\(class\\|def\)\s', '')<CR>
25+
vnoremap <buffer> [[ :call pymode#motion#vmove('^\(class\\|def\)\s', 'b')<CR>
26+
vnoremap <buffer> ]M :call pymode#motion#vmove('^\s*def\s', '')<CR>
27+
vnoremap <buffer> [M :call pymode#motion#vmove('^\s*def\s', 'b')<CR>
2828
2929
onoremap <buffer> C :<C-U>call pymode#motion#select('^\s*class\s', 0)<CR>
3030
onoremap <buffer> aC :<C-U>call pymode#motion#select('^\s*class\s', 0)<CR>

autoload/pymode.vim

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
" Python-mode base functions
2+
3+
14
fun! pymode#Default(name, default) "{{{
5+
" DESC: Set default value if it not exists
6+
"
27
if !exists(a:name)
38
let {a:name} = a:default
49
return 0
510
endif
611
return 1
712
endfunction "}}}
813

14+
915
fun! pymode#QuickfixOpen(onlyRecognized, holdCursor, maxHeight, minHeight, jumpError) "{{{
16+
" DESC: Open quickfix window
17+
"
1018
let numErrors = len(filter(getqflist(), 'v:val.valid'))
1119
let numOthers = len(getqflist()) - numErrors
1220
if numErrors > 0 || (!a:onlyRecognized && numOthers > 0)
@@ -30,6 +38,8 @@ endfunction "}}}
3038

3139

3240
fun! pymode#PlaceSigns() "{{{
41+
" DESC: Place error signs
42+
"
3343
sign unplace *
3444
for item in filter(getqflist(), 'v:val.bufnr != ""')
3545
execute printf('silent! sign place 1 line=%d name=%s buffer=%d', item.lnum, item.type, item.bufnr)
@@ -38,6 +48,8 @@ endfunction "}}}
3848

3949

4050
fun! pymode#CheckProgram(name, append) "{{{
51+
" DESC: Check program is executable or redifined by user.
52+
"
4153
let name = 'g:' . a:name
4254
if pymode#Default(name, a:name)
4355
return 1
@@ -49,21 +61,29 @@ fun! pymode#CheckProgram(name, append) "{{{
4961
return 1
5062
endfunction "}}}
5163

64+
5265
fun! pymode#TempBuffer() "{{{
66+
" DESC: Open temp buffer.
67+
"
5368
pclose | botright 8new
5469
setlocal buftype=nofile bufhidden=delete noswapfile nowrap previewwindow
5570
redraw
5671
endfunction "}}}
5772

73+
5874
fun! pymode#ShowStr(str) "{{{
75+
" DESC: Open temp buffer with `str`.
76+
"
5977
call pymode#TempBuffer()
6078
put! =a:str
6179
redraw
62-
normal gg
63-
wincmd p
80+
normal gg | wincmd p
6481
endfunction "}}}
6582

83+
6684
fun! pymode#ShowCommand(cmd) "{{{
85+
" DESC: Run command and open temp buffer with result
86+
"
6787
call pymode#TempBuffer()
6888
try
6989
silent exec 'r!' . a:cmd
@@ -72,16 +92,57 @@ fun! pymode#ShowCommand(cmd) "{{{
7292
echoerr 'Command fail: '.a:cmd
7393
endtry
7494
redraw
75-
normal gg
76-
wincmd p
95+
normal gg | wincmd p
7796
endfunction "}}}
7897

7998

80-
" DESC: Show wide message
8199
fun! pymode#WideMessage(msg) "{{{
100+
" DESC: Show wide message
101+
82102
let x=&ruler | let y=&showcmd
83103
set noruler noshowcmd
84104
redraw
85105
echo strpart(a:msg, 0, &columns-1)
86106
let &ruler=x | let &showcmd=y
87107
endfunction "}}}
108+
109+
110+
fun! pymode#BlockStart(lnum, ...) "{{{
111+
let pattern = a:0 ? a:1 : '^\s*\(@\|class\s.*:\|def\s\)'
112+
let lnum = a:lnum + 1
113+
let indent = 100
114+
while lnum
115+
let lnum = prevnonblank(lnum - 1)
116+
let test = indent(lnum)
117+
let line = getline(lnum)
118+
if line =~ '^\s*#' " Skip comments
119+
continue
120+
elseif !test " Zero-level regular line
121+
return lnum
122+
elseif test >= indent " Skip deeper or equal lines
123+
continue
124+
" Indent is strictly less at this point: check for def/class
125+
elseif line =~ pattern && line !~ '^\s*@'
126+
return lnum
127+
endif
128+
let indent = indent(lnum)
129+
endwhile
130+
return 0
131+
endfunction "}}}
132+
133+
134+
fun! pymode#BlockEnd(lnum, ...) "{{{
135+
let indent = a:0 ? a:1 : indent(a:lnum)
136+
let lnum = a:lnum
137+
while lnum
138+
let lnum = nextnonblank(lnum + 1)
139+
if getline(lnum) =~ '^\s*#' | continue
140+
elseif lnum && indent(lnum) <= indent
141+
return lnum - 1
142+
endif
143+
endwhile
144+
return line('$')
145+
endfunction "}}}
146+
147+
148+
" vim: fdm=marker:fdl=0

autoload/pymode/doc.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
" Python-mode search by documentation
2+
3+
14
fun! pymode#doc#Show(word) "{{{
25
if a:word == ''
36
echoerr "No name/symbol under cursor!"
@@ -13,3 +16,6 @@ fun! pymode#doc#Show(word) "{{{
1316
wincmd p
1417
endif
1518
endfunction "}}}
19+
20+
21+
" vim: fdm=marker:fdl=0

0 commit comments

Comments
 (0)