"
" This plugin allows you to asynchronously call pylint.
"
-" * Add %{LintStatus()} to your statusline to see if pylint is running
" * Press <F6> to start pylint on current file
" * Press <S-F6> to open quickfix window with messages from pylint
" * All lines with corresponding pylint existing warning will be highlighted
" Start pylint manually (<F6>) to force its filling
" * After Python file is saved, pylint is automatically started
-if exists('g:loaded_pylint') | finish | endif
-let g:loaded_pylint = 1
-
-function! LintStatus()
- if exists("b:lint_job") && job_status(b:lint_job) == "run" | return "LN" | endif
+function! python#lint#status()
+ if exists("b:pylint_job") && job_status(b:pylint_job) == "run" | return "LN" | endif
return ""
endfunction
-function! s:qffill(ch)
+function! s:qffill(ch) abort
let msgs = []
while ch_status(a:ch) == 'buffered'
let msgs = add(msgs, ch_read(a:ch))
sign define LN text=LN texthl=Error
-function! PylintFinish(ch)
+function! python#lint#finish(ch) abort
let l:errorformat_bak = &errorformat
set errorformat=%f:%l:\ [%t]%m,%f:%l:%m
call s:qffill(a:ch)
endif
endfunction
-function! PylintStart()
- if exists("g:pylint_disable") || (exists("b:lint_job") && job_status(b:lint_job) == "run")
+function! python#lint#start() abort
+ if exists("g:pylint_disable") ||
+ \ (exists("b:pylint_job") &&
+ \ job_status(b:pylint_job) == "run")
return
endif
let ignores = [
\"too-many-public-methods",
\"no-value-for-parameter",
\]
- if !exists("g:pylint_linter") | let g:pylint_linter = "pylint" | endif
- if g:pylint_linter == "flake8"
+ let linter = get(g:, "pylint_linter", "pylint")
+ if linter == "flake8"
let cmdline = [
\"flake8",
\"--ignore=E501",
\"--max-line-length=90",
\expand("%p")
\]
- elseif g:pylint_linter == "pylint"
+ elseif linter == "pylint"
let cmdline = [
\"pylint",
\"--jobs=4",
echohl WarningMsg | echomsg "Unknown linter specified" | echohl None
return
endif
- let b:lint_job = job_start(cmdline, {"in_mode": "nl", "err_io": "null", "close_cb": "PylintFinish"})
-endfunction()
-
-map <F6> :unlet! g:pylint_disable<CR>:call PylintStart()<CR>
-map \e[32~ :redraw!<CR>:copen<CR>
-autocmd BufWritePost *.py call PylintStart()
+ let b:pylint_job = job_start(cmdline,
+ \ {"in_mode": "nl", "err_io": "null", "close_cb": "python#lint#finish"})
+endfunction