Skip to content

Commit fbdb8ca

Browse files
committed
Support sorting by relevance in code checking.
1 parent 411a74d commit fbdb8ca

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

Changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ Changelog
3131
'pymode_rope_goto_def_newwin', 'pymode_rope_always_show_complete_menu'
3232

3333
* Options added:
34-
'pymode_rope_regenerate_on_write', 'pymode_rope_completion', 'pymode_rope_complete_on_dot'
34+
'pymode_rope_regenerate_on_write', 'pymode_rope_completion', 'pymode_rope_complete_on_dot',
35+
'pymode_lint_sort'
3536

3637
* Commands added:
3738
'PymodeVirtualenv'

doc/pymode.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ By example you disable all warnings starting from 'W', but want to see warning
301301
>
302302
let g:pymode_lint_select = "E501,W0011,W430"
303303
304+
Sort errors by relevance *'g:pymode_lint_sort'*
305+
If not emply, errors will be sort by defined relevance
306+
E.g. let g:pymode_lint_sort = ['E', 'C', 'I'] " Errors first 'E',
307+
after them 'C' and ...
308+
>
309+
let g:pymode_lint_sort = []
310+
304311
Auto open cwindow (quickfix) if any errors has been finded
305312
*'g:pymode_lint_cwindow'*
306313
>

plugin/pymode.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ call pymode#default("g:pymode_lint_select", "")
103103
" Auto open cwindow if any errors has been finded
104104
call pymode#default("g:pymode_lint_cwindow", 1)
105105

106+
" If not emply, errors will be sort by defined relevance
107+
" E.g. let g:pymode_lint_sort = ['E', 'C', 'I'] " Errors first 'E',
108+
" after them 'C' and ...
109+
call pymode#default("g:pymode_lint_sort", [])
110+
106111
" Place error signs
107112
call pymode#default("g:pymode_lint_signs", 1)
108113

@@ -233,6 +238,10 @@ if &compatible
233238
endif
234239
filetype plugin on
235240

241+
if exists('+shellslash')
242+
set shellslash
243+
endif
244+
236245
" Disable python-related functionality
237246
" let g:pymode_python = 'disable'
238247
" let g:pymode_python = 'python3'

pymode/lint.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,17 @@ def code_check():
3232
return False
3333

3434
errors = check_path(path, options=options)
35+
sort_rules = vim.eval('g:pymode_lint_sort')
36+
37+
def sort(e):
38+
try:
39+
print(e.get('type'))
40+
return sort_rules.index(e.get('type'))
41+
except ValueError:
42+
return 999
43+
44+
if sort_rules:
45+
print(sort_rules)
46+
errors = sorted(errors, key=sort)
47+
3548
vim.command('call setqflist(%s)' % json.dumps(errors))

0 commit comments

Comments
 (0)