I'm writing small liniting plugin and I want to show errors in the quickfix as soon as errorfile changes.
fu! OpenErrors(job_id, data, event)
let l:winid = win_getid()
let l:output = split(a:data[0])
echom l:output[0] . l:output[2]
let l:view = winsaveview()
exe 'silent! cfile! ' . escape(l:output[0] . l:output[2], '%#/')
call winrestview(l:view)
if len(getqflist()) > 0
copen
else
cclose
endif
call win_gotoid(l:winid)
endfu
The problems with this code is that it the cursor jumps to quickfix window and it's annoying when errorfile changes fast.