Skip to content

Commit 550f55c

Browse files
committed
Fix bugs.
1 parent 0d448ad commit 550f55c

File tree

12 files changed

+60
-32
lines changed

12 files changed

+60
-32
lines changed

Changelog.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ Changelog
2121
'pymode_rope_enable_autoimport' -> 'pymode_rope_autoimport'
2222

2323
* Options removed:
24+
2425
'pymode_lint_hold', 'pymode_lint_config', 'pymode_lint_jump',
2526
'pymode_lint_signs_always_visible', 'pymode_rope_extended_complete',
2627
'pymode_rope_auto_project', 'pymode_rope_autoimport_generate',
2728
'pymode_rope_autoimport_underlines', 'pymode_rope_codeassist_maxfixes',
2829
'pymode_rope_sorted_completions', 'pymode_rope_extended_complete',
2930
'pymode_rope_confirm_saving', 'pymode_rope_global_prefix',
30-
'pymode_rope_local_prefix', 'pymode_rope_vim_completion', 'pymode_rope_guess_project',
31-
'pymode_rope_goto_def_newwin', 'pymode_rope_always_show_complete_menu'
31+
'pymode_rope_local_prefix', 'pymode_rope_vim_completion',
32+
'pymode_rope_guess_project', 'pymode_rope_goto_def_newwin',
33+
'pymode_rope_always_show_complete_menu'
3234

3335
* Options added:
34-
'pymode_rope_regenerate_on_write', 'pymode_rope_completion', 'pymode_rope_complete_on_dot',
35-
'pymode_lint_sort'
36+
'pymode_rope_regenerate_on_write', 'pymode_rope_completion',
37+
'pymode_rope_complete_on_dot', 'pymode_lint_sort',
38+
'pymode_rope_look_project', 'pymode_lint_unmodified'
3639

3740
* Commands added:
3841
'PymodeVirtualenv'

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ clean:
99
# Temporary disable rope tests on Travis
1010
.PHONY: travis
1111
travis:
12-
rm -rf t/rope.vim
12+
# rm -rf t/rope.vim
1313
rake test
1414

1515
.PHONY: test

autoload/pymode.vim

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,22 @@ endfunction "}}}
106106

107107
fun! pymode#buffer_pre_write() "{{{
108108
let b:pymode_modified = &modified
109+
if g:pymode_lint_unmodified || (g:pymode_lint_on_write && b:pymode_modified)
110+
call pymode#debug('check code')
111+
call pymode#lint#check()
112+
endif
109113
endfunction
110114

111115
fun! pymode#buffer_post_write() "{{{
112116
if b:pymode_modified && g:pymode_rope_regenerate_on_write
117+
call pymode#debug('regenerate')
113118
call pymode#rope#regenerate()
114119
endif
115-
if g:pymode_lint_on_write && (b:pymode_modified || g:pymode_lint_unmodified)
116-
call pymode#lint#check()
120+
endfunction "}}}
121+
122+
fun! pymode#debug(msg) "{{{
123+
if g:pymode_debug
124+
let g:pymode_debug += 1
125+
echom string(g:pymode_debug) . ': ' . string(a:msg)
117126
endif
118127
endfunction "}}}

autoload/pymode/lint.vim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ endfunction "}}}
4848
fun! pymode#lint#check() "{{{
4949
" DESC: Run checkers on current file.
5050
"
51-
if !g:pymode_lint | return | endif
52-
5351
let loclist = g:PymodeLocList.current()
5452

5553
let b:pymode_error_line = -1
@@ -64,13 +62,13 @@ fun! pymode#lint#check() "{{{
6462
call pymode#wide_message('Code checking is completed. No errors found.')
6563
endif
6664

65+
call g:PymodeSigns.refresh(loclist)
66+
6767
if g:pymode_lint_cwindow
6868
call setqflist(loclist._loclist)
6969
call pymode#quickfix_open(0, g:pymode_quickfix_maxheight, g:pymode_quickfix_minheight, 0)
7070
endif
7171

72-
call g:PymodeSigns.refresh(loclist)
73-
7472
call pymode#lint#show_errormessage()
7573
call pymode#wide_message('Found errors and warnings: ' . len(loclist._loclist))
7674

autoload/pymode/tools/loclist.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fun! g:PymodeLocList.current() "{{{
1818
if !exists("b:pymode_loclist")
1919
let b:pymode_loclist = g:PymodeLocList.init([])
2020
endif
21+
let b:pymode_loclist._bufnr = bufnr('.')
2122
return b:pymode_loclist
2223
endfunction "}}}
2324

@@ -30,6 +31,7 @@ endfunction "}}}
3031
fun! g:PymodeLocList.clear() "{{{
3132
let self._loclist = []
3233
let self._messages = {}
34+
let self._bufnr = bufnr('')
3335
endfunction "}}}
3436

3537

autoload/pymode/tools/signs.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ endfunction "}}}
4545

4646
fun! g:PymodeSigns.place(loclist) "{{{
4747
let seen = {}
48-
let buf = bufnr('')
4948
for issue in a:loclist._loclist
5049
if !has_key(seen, issue.lnum)
5150
let seen[issue.lnum] = 1
5251
call add(self._sign_ids, self._next_id)
53-
execute printf('sign place %d line=%d name=%s buffer=%d', self._next_id, issue.lnum, "Pymode".issue.type[0], buf)
52+
execute printf('sign place %d line=%d name=%s buffer=%d', self._next_id, issue.lnum, "Pymode".issue.type[0], issue.bufnr)
5453
let self._next_id += 1
5554
endif
5655
endfor

doc/pymode.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ Commands:
346346
|:PymodeRopeRenameModule| -- Rename current module
347347
|:PymodeRopeUndo| -- Undo changes from last refactoring
348348

349+
350+
Turn on the rope script *'g:pymode_rope'*
351+
>
352+
let g:pymode_rope = 1
353+
349354
.roperoject Folder ~
350355
*.ropeproject*
351356

@@ -366,10 +371,18 @@ Currently it is used for things such as:
366371
* It can be used for saving object information to help rope object inference.
367372
* It can be used for saving global names cache which is used in auto-import.
368373

374+
If ``.ropeproject`` is not found in the current directory, rope will walk
375+
upwards looking for a ``.ropeproject`` in every dir of the parent path. If
376+
rope finds ``.ropeproject`` in a parent dir, it sets the project for all child
377+
dirs and the scan may be slow for so many dirs and files.
369378

370-
Turn on the rope script *'g:pymode_rope'*
379+
Enable search |.ropeproject| in parent's directories
380+
*'g:pymode_rope_look_project'*
371381
>
372-
let g:pymode_rope = 1
382+
let g:pymode_rope_look_project = 1
383+
384+
385+
Show documentation for element under cursor ~
373386

374387
Show documentation for object under cursor. *'g:pymode_rope_show_doc_bind'*
375388
Leave empty for disable key binding.
@@ -628,6 +641,8 @@ Solutions:
628641
in the current dir.
629642
- Run ``:PymodeRopeNewProject`` to make rope create ``.ropeproject`` in the
630643
current dir.
644+
- Set |'g:pymode_rope_look_project'| to 0 for prevent searching in parent
645+
dirs.
631646

632647

633648
Pylint check is very slow

ftplugin/python/pymode.vim

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ if !pymode#default('g:pymode_init', 1)
1111
PymodePython patch_paths()
1212
endif
1313

14-
augroup pymode
15-
16-
au!
17-
1814
command! -buffer -nargs=1 PymodeVirtualenv call pymode#virtualenv#activate(<args>)
1915

2016
" Setup events for pymode
21-
au BufWritePre <buffer> call pymode#buffer_pre_write()
22-
au BufWritePost <buffer> call pymode#buffer_post_write()
17+
au! pymode BufWritePre <buffer> call pymode#buffer_pre_write()
18+
au! pymode BufWritePost <buffer> call pymode#buffer_post_write()
2319

2420
" Run python code
2521
if g:pymode_run
@@ -74,12 +70,12 @@ if g:pymode_lint
7470
let b:pymode_error_line = -1
7571

7672
if g:pymode_lint_on_fly
77-
au! InsertLeave <buffer> PymodeLint
73+
au! pymode InsertLeave <buffer> PymodeLint
7874
endif
7975

8076
if g:pymode_lint_message
81-
au! CursorMoved <buffer>
82-
au! CursorMoved <buffer> call pymode#lint#show_errormessage()
77+
au! pymode CursorMoved <buffer>
78+
au! pymode CursorMoved <buffer> call pymode#lint#show_errormessage()
8379
endif
8480

8581
" Disabled for current release
@@ -187,5 +183,3 @@ if g:pymode_rope
187183
end
188184

189185
end
190-
191-
augroup END

plugin/pymode.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ call pymode#default('g:pymode_breakpoint_cmd', '')
144144
" Rope support
145145
call pymode#default('g:pymode_rope', 1)
146146

147+
" If project hasnt been finded in current working directory, look at parents directory
148+
call pymode#default('g:pymode_rope_look_project', 1)
149+
147150
" Enable Rope completion
148151
call pymode#default('g:pymode_rope_completion', 1)
149152

pymode/lint.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,8 @@ def __sort(e):
5050
if sort_rules:
5151
errors = sorted(errors, key=__sort)
5252

53+
for e in errors:
54+
e['bufnr'] = b.number
55+
5356
vim.command(
5457
'call g:PymodeLocList.current().extend(%s)' % json.dumps(errors))

0 commit comments

Comments
 (0)