forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloclist.vim
More file actions
99 lines (78 loc) · 2.39 KB
/
loclist.vim
File metadata and controls
99 lines (78 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
let g:PymodeLocList= {}
fun! pymode#tools#loclist#init() "{{{
return
endfunction "}}}
fun! g:PymodeLocList.init(raw_list) "{{{
let obj = copy(self)
let loc_list = filter(copy(a:raw_list), 'v:val["valid"] == 1')
call obj.clear()
let obj._title = 'CodeCheck'
return obj
endfunction "}}}
fun! g:PymodeLocList.current() "{{{
if !exists("b:pymode_loclist")
let b:pymode_loclist = g:PymodeLocList.init([])
endif
return b:pymode_loclist
endfunction "}}}
fun! g:PymodeLocList.is_empty() "{{{
return empty(self._errlist) && empty(self._warnlist)
endfunction "}}}
fun! g:PymodeLocList.loclist() "{{{
let loclist = copy(self._errlist)
call extend(loclist, self._warnlist)
return loclist
endfunction "}}}
fun! g:PymodeLocList.num_errors() "{{{
return len(self._errlist)
endfunction "}}}
fun! g:PymodeLocList.num_warnings() "{{{
return len(self._warnlist)
endfunction "}}}
fun! g:PymodeLocList.clear() "{{{
let self._errlist = []
let self._warnlist = []
let self._messages = {}
let self._name = expand('%:t')
endfunction "}}}
fun! g:PymodeLocList.extend(raw_list) "{{{
let err_list = filter(copy(a:raw_list), 'v:val["type"] == "E"')
let warn_list = filter(copy(a:raw_list), 'v:val["type"] != "E"')
call extend(self._errlist, err_list)
call extend(self._warnlist, warn_list)
for issue in a:raw_list
let self._messages[issue.lnum] = issue.text
endfor
return self
endfunction "}}}
fun! g:PymodeLocList.filter(filters) "{{{
let loclist = []
for error in self.loclist()
let passes_filters = 1
for key in keys(a:filters)
if get(error, key, '') !=? a:filters[key]
let passes_filters = 0
break
endif
endfor
if passes_filters
call add(loclist, error)
endif
endfor
return loclist
endfunction "}}}
fun! g:PymodeLocList.show() "{{{
call setloclist(0, self.loclist())
if self.is_empty()
lclose
elseif g:pymode_lint_cwindow
let num = winnr()
lopen
setl nowrap
execute max([min([line("$"), g:pymode_quickfix_maxheight]), g:pymode_quickfix_minheight]) . "wincmd _"
if num != winnr()
call setwinvar(winnr(), 'quickfix_title', self._title . ' <' . self._name . '>')
exe num . "wincmd w"
endif
end
endfunction "}}}