Skip to content

Cooperate with famous plugins

Linwei edited this page Nov 2, 2016 · 25 revisions

errormarker

errormarker is a plugin to highlights and sets error markers for lines with compile errors. It is very handy and has more than 5K downloads in vim.org.

This plugin relys on an autocmd named QuickFixCmdPost make which will be triggered at the end of ':make' command. And we can trigger that autocmd by setting "g:asyncrun_auto" to "make":

let g:asyncrun_auto = "make"

This will execute an "doautocmd QuickFixCmdPost make" after background job finished and get errormaker to read ahd process the content of quickfix window:

Now when any AsyncRun command completes, errormaker will show the markers and ballons on the errors and warnings of source file. It's pretty cool.

Here you may ask, "it is a very useful autocmd why doesn't asyncrun trigger it by default ?"

Because many people may set a quickfixpost command to translate encoding in quickfix window like below, which will make a strange experience with asyncrun:

	function QfMakeConv()
	   let qflist = getqflist()
	   for i in qflist
	      let i.text = iconv(i.text, "cp936", "utf-8")
	   endfor
	   call setqflist(qflist)
	endfunction

	au QuickfixCmdPost make call QfMakeConv()

This piece of code is from :h QuickFixCmdPost-example, many non-english-speaking people use it. setqflist will cause the cursor of quickfix window rewind to the first line, it's innocuity in the old days, but very ugly with async jobs.

There is an local autocmd option -auto=? here if you want to trigger the autocmd just for current command:

:AsyncRun -auto=make gcc %

So, both 'g:asyncrun_auto' and '-auto=?' can errormaker to work.

fugitive

see here

(this page is still editing in progress ...)

Clone this wiki locally