X-Git-Url: http://www.git.stargrave.org/?p=dotfiles.git;a=blobdiff_plain;f=vim%2F.vim%2Fpack%2Fstargrave%2Fstart%2Fpy-flake8%2Fautoload%2Fpython%2Flint.vim;fp=vim%2F.vim%2Fpack%2Fstargrave%2Fstart%2Fpy-flake8%2Fautoload%2Fpython%2Flint.vim;h=10d3fc208aa0501ce754bb60bf4a49b3c32dfc00;hp=0000000000000000000000000000000000000000;hb=18761fd15fd6acd4b9c9c9cd0d1792f8099b1e41;hpb=4b062e2c0a4dddff0bb8225bde2061f65134fa8b diff --git a/vim/.vim/pack/stargrave/start/py-flake8/autoload/python/lint.vim b/vim/.vim/pack/stargrave/start/py-flake8/autoload/python/lint.vim new file mode 100644 index 0000000..10d3fc2 --- /dev/null +++ b/vim/.vim/pack/stargrave/start/py-flake8/autoload/python/lint.vim @@ -0,0 +1,62 @@ +vim9script + +# Asynchronous pylint utility call +# Maintainer: Sergey Matveev +# License: GNU General Public License version 3 of the License or later +# +# This plugin allows you to asynchronously call pylint. +# +# * Press to start pylint on current file +# * Press to open quickfix window with messages from pylint +# * All lines with corresponding pylint existing warning will be highlighted +# * If no warning and errors occurred, "pylint is clean" message will be shown +# * If existing quickfix window is found, then it won't be overwritten. +# Start pylint manually () to force its filling + +export def Status(): string + if exists("b:pylint_job") && job_status(b:pylint_job) == "run" | return "LN" | endif + return "" +enddef + +def Qffill(ch: channel) + var msgs = [] + while ch_status(ch) == "buffered" + msgs = add(msgs, ch_read(ch)) + endwhile + cgetexpr msgs +enddef + +export def Finish(ch: channel) + var errorformat_bak = &errorformat + set errorformat=%f:%l:\ [%t]%m,%f:%l:%m + Qffill(ch) + &errorformat = errorformat_bak + sign unplace * + var id = 2 + for item in getqflist() + if item.lnum == 0 | continue | endif + execute(":sign place " .. id .. + " name=LN line=" .. item.lnum .. " buffer=" .. item.bufnr) + id = id + 2 + endfor + redraw! + if id == 2 + echohl MoreMsg | echomsg "pylint is clean" | echohl None + cclose + endif +enddef + +export def Start() + if exists("b:pylint_job") && job_status(b:pylint_job) == "run" + return + endif + var cmdline = [ + "flake8", + "--ignore=E501", + "--format=%(path)s:%(row)d: [%(code)s] %(text)s", + "--max-line-length=90", + expand("%p") + ] + b:pylint_job = job_start(cmdline, + {"in_mode": "nl", "err_io": "null", "close_cb": "python#lint#Finish"}) +enddef