forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint.vim
More file actions
108 lines (86 loc) · 2.55 KB
/
lint.vim
File metadata and controls
108 lines (86 loc) · 2.55 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
100
101
102
103
104
105
106
107
108
fun! pymode#lint#Check() "{{{
" DESC: Run checkers on current file.
"
if !g:pymode_lint | return | endif
if &modifiable && &modified
try
noautocmd write
catch /E212/
echohl Error | echo "File modified and I can't save it. Cancel code checking." | echohl None
return 0
endtry
endif
let g:pymode_lint_buffer = bufnr('%')
py from pymode import lint
py lint.check_file()
endfunction " }}}
fun! pymode#lint#Parse(bnum)
" DESC: Parse result of code checking.
"
call setqflist(g:qf_list, 'r')
if g:pymode_lint_signs
call pymode#PlaceSigns(a:bnum)
endif
if g:pymode_lint_cwindow
call pymode#QuickfixOpen(0, g:pymode_lint_hold, g:pymode_lint_maxheight, g:pymode_lint_minheight, g:pymode_lint_jump)
endif
if !len(g:qf_list)
call pymode#WideMessage('Code checking is completed. No errors found.')
endif
endfunction
fun! pymode#lint#Toggle() "{{{
let g:pymode_lint = g:pymode_lint ? 0 : 1
call pymode#lint#toggle_win(g:pymode_lint, "Pymode lint")
endfunction "}}}
fun! pymode#lint#ToggleWindow() "{{{
let g:pymode_lint_cwindow = g:pymode_lint_cwindow ? 0 : 1
call pymode#lint#toggle_win(g:pymode_lint_cwindow, "Pymode lint cwindow")
endfunction "}}}
fun! pymode#lint#ToggleChecker() "{{{
let g:pymode_lint_checker = g:pymode_lint_checker == "pylint" ? "pyflakes" : "pylint"
echomsg "Pymode lint checker: " . g:pymode_lint_checker
endfunction "}}}
fun! pymode#lint#toggle_win(toggle, msg) "{{{
if a:toggle
echomsg a:msg." enabled"
botright cwindow
if &buftype == "quickfix"
wincmd p
endif
else
echomsg a:msg." disabled"
cclose
endif
endfunction "}}}
fun! pymode#lint#show_errormessage() "{{{
if g:pymode_lint_buffer != bufnr('%')
return 0
endif
let errors = getqflist()
if !len(errors)
return
endif
let [_, line, _, _] = getpos(".")
for e in errors
if e['lnum'] == line
call pymode#WideMessage(e['text'])
else
echo
endif
endfor
endfunction " }}}
fun! pymode#lint#Auto() "{{{
if &modifiable && &modified
try
noautocmd write
catch /E212/
echohl Error | echo "File modified and I can't save it. Cancel operation." | echohl None
return 0
endtry
endif
py from pymode import auto
py auto.fix_current_file()
cclose
edit
call pymode#WideMessage("AutoPep8 done.")
endfunction "}}}