1 " Asynchronous pylint utility call
2 " Maintainer: Sergey Matveev <stargrave@stargrave.org>
3 " License: GNU General Public License version 3 of the License or later
5 " This plugin allows you to asynchronously call pylint.
7 " * Press <F6> to start pylint on current file
8 " * Press <S-F6> to open quickfix window with messages from pylint
9 " * All lines with corresponding pylint existing warning will be highlighted
10 " * If no warning and errors occurred, "pylint is clean" message will be shown
11 " * If existing quickfix window is found, then it won't be overwritten.
12 " Start pylint manually (<F6>) to force its filling
13 " * After Python file is saved, pylint is automatically started
15 function! python#lint#status()
16 if exists("b:pylint_job") && job_status(b:pylint_job) == "run" | return "LN" | endif
20 function! s:qffill(ch) abort
22 while ch_status(a:ch) == 'buffered'
23 let msgs = add(msgs, ch_read(a:ch))
28 sign define LN text=LN texthl=Error
30 function! python#lint#finish(ch) abort
31 let l:errorformat_bak = &errorformat
32 set errorformat=%f:%l:\ [%t]%m,%f:%l:%m
34 let &errorformat=l:errorformat_bak
37 for item in getqflist()
38 if item.lnum == 0 | continue | endif
39 execute(':sign place '.l:id.' name=LN line='.l:item.lnum.' buffer='.l:item.bufnr)
44 echohl MoreMsg | echomsg "pylint is clean" | echohl None
49 function! python#lint#start() abort
50 if exists("g:pylint_disable") ||
51 \ (exists("b:pylint_job") &&
52 \ job_status(b:pylint_job) == "run")
59 \"too-few-public-methods",
61 \"too-many-instance-attributes",
63 \"too-many-arguments",
65 \"too-many-public-methods",
66 \"no-value-for-parameter",
68 let linter = get(g:, "pylint_linter", "flake8")
73 \"--format=%(path)s:%(row)d: [%(code)s] %(text)s",
74 \"--max-line-length=90",
77 elseif linter == "pylint"
82 \"--msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}",
83 \"--disable=" . join(ignores, ","),
89 echohl WarningMsg | echomsg "Unknown linter specified" | echohl None
92 let b:pylint_job = job_start(cmdline,
93 \ {"in_mode": "nl", "err_io": "null", "close_cb": "python#lint#finish"})