Skip to content

Commit 7c2201f

Browse files
Will Lediraol
authored andcommitted
Modify loclist
- Separate errors from warnings (errors are shown above warnings) - [g:pymode_lint_cwindow] open loclist only if there is at least one error (not warnings) - [g:pymode_lint_cwindow] jump to first error Changes to be committed: modified: autoload/pymode/lint.vim modified: autoload/pymode/tools/loclist.vim modified: autoload/pymode/tools/signs.vim modified: pymode/rope.py
1 parent a68a7a3 commit 7c2201f

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

autoload/pymode/lint.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fun! pymode#lint#check() "{{{
6969
call loclist.show()
7070

7171
call pymode#lint#show_errormessage()
72-
call pymode#wide_message('Found errors and warnings: ' . len(loclist._loclist))
72+
call pymode#wide_message('Found ' . loclist.num_errors() . ' error(s) and ' . loclist.num_warnings() . ' warning(s)')
7373

7474
endfunction " }}}
7575

autoload/pymode/tools/loclist.vim

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,37 @@ endfunction "}}}
2424

2525

2626
fun! g:PymodeLocList.is_empty() "{{{
27-
return empty(self._loclist)
27+
return empty(self._errlist) && empty(self._warnlist)
28+
endfunction "}}}
29+
30+
fun! g:PymodeLocList.loclist() "{{{
31+
let loclist = copy(self._errlist)
32+
call extend(loclist, self._warnlist)
33+
return loclist
34+
endfunction "}}}
35+
36+
fun! g:PymodeLocList.num_errors() "{{{
37+
return len(self._errlist)
38+
endfunction "}}}
39+
40+
fun! g:PymodeLocList.num_warnings() "{{{
41+
return len(self._warnlist)
2842
endfunction "}}}
2943

3044

3145
fun! g:PymodeLocList.clear() "{{{
32-
let self._loclist = []
46+
let self._errlist = []
47+
let self._warnlist = []
3348
let self._messages = {}
3449
let self._name = expand('%:t')
3550
endfunction "}}}
3651

3752

3853
fun! g:PymodeLocList.extend(raw_list) "{{{
39-
call extend(self._loclist, a:raw_list)
54+
let err_list = filter(copy(a:raw_list), 'v:val["type"] == "E"')
55+
let warn_list = filter(copy(a:raw_list), 'v:val["type"] != "E"')
56+
call extend(self._errlist, err_list)
57+
call extend(self._warnlist, warn_list)
4058
for issue in a:raw_list
4159
let self._messages[issue.lnum] = issue.text
4260
endfor
@@ -46,7 +64,7 @@ endfunction "}}}
4664

4765
fun! g:PymodeLocList.filter(filters) "{{{
4866
let loclist = []
49-
for error in self._loclist
67+
for error in self.loclist()
5068
let passes_filters = 1
5169
for key in keys(a:filters)
5270
if get(error, key, '') !=? a:filters[key]
@@ -65,8 +83,9 @@ endfunction "}}}
6583

6684

6785
fun! g:PymodeLocList.show() "{{{
68-
call setloclist(0, self._loclist)
69-
if self.is_empty()
86+
call setloclist(0, self.loclist())
87+
"if self.is_empty()
88+
if self.num_errors() == 0
7089
lclose
7190
elseif g:pymode_lint_cwindow
7291
let num = winnr()
@@ -77,5 +96,6 @@ fun! g:PymodeLocList.show() "{{{
7796
call setwinvar(winnr(), 'quickfix_title', self._title . ' <' . self._name . '>')
7897
exe num . "wincmd w"
7998
endif
80-
endif
99+
lfirst
100+
end
81101
endfunction "}}}

autoload/pymode/tools/signs.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ endfunction "}}}
4646

4747
fun! g:PymodeSigns.place(loclist) "{{{
4848
let seen = {}
49-
for issue in a:loclist._loclist
49+
for issue in a:loclist.loclist()
5050
if !has_key(seen, issue.lnum)
5151
let seen[issue.lnum] = 1
5252
call add(self._sign_ids, self._next_id)

pymode/rope.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def find_it():
184184
text=env.lines[oc.lineno - 1] if oc.resource.real_path == env.curbuf.name else "", # noqa
185185
lnum=oc.lineno,
186186
))
187-
env.let('loclist._loclist', lst)
187+
env.run('g:PymodeLocList.current().extend', lst)
188188

189189

190190
def update_python_path(paths):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy