Get AsyncCommand working with error?

I found AsyncCommand on https://stackoverflow.com/a/2/3129/ and found it to be a terrific tool! I am trying to get it to work with the errormarker plugin , but have encountered some problems.

I don’t know exactly what the problem is. I traced the errormarker script and found that using the error after the script to bind QuickFixCmdPostto the event and set markers in the lines of the source files.

augroup errormarker
    autocmd QuickFixCmdPost make call <SID>SetErrorMarkers()
augroup END

According to the :helpsecond argument ( make) is the patternfile (for example:) *.html. I am not a file template make, I tried

autocmd QuickFixCmdPost AsyncMake call <SID>SetErrorMarkers()

This does not work (required). But I do not know what else I can do. I am doing a googled "AsyncCommand errormarker" but am not getting anything.

Are there any comments? Any suggestion is welcome. Thanks in advance.

+2
source share
2 answers

I have found a solution.

The solution works, but is ugly.

The key should automatically call the function errormarker SetErrorMarkers()at the right time.

I tried Peter Rinker's solution, but it turned out that I AsyncCommandQuickFixCmdPostshot too early. The quickfix list is not yet installed. Therefore SetErrorMarkers()does nothing.

I read the manual AsyncCommandand traced some code, AsyncMakeis actually a wrapper that calls

asynccommand#run(cmd, handler)

with

asynccommand#run("make", asynchandler#qf)
// where asynchandler#qf is the handler to read quick fix list back.

, asynchandler#qf , asynchandler#qf asynccommand#done asynccommand.vim 92, asynchandler#qf.

function! asynccommand#done(temp_file_name)
  " Called on completion of the task
  let r = s:receivers[a:temp_file_name] "handlers are registered in s:receivers
  if type(r.dict) == type({})
    call call(r.func, [a:temp_file_name], r.dict)
  else
    call call(r.func, [a:temp_file_name])
  endif
  unlet s:receivers[a:temp_file_name]
  delete a:temp_file_name
endfunction

!

101 SetErrorMarkers()

  ...
  unlet s:receivers[a:temp_file_name]
  if exists("*ExposeSetErrorMarkers")
    call ExposeSetErrorMarkers()
  endif
  delete a:temp_file_name
  ...

, ExposeSetErrorMarkers() not SetErrorMarkers(). SetErrorMarkers() script, script. ExposeSetErrorMarkers() errormarker.vim, .

function! ExposeSetErrorMarkers()
    call s:SetErrorMarkers()
endfunction

, .vimrc

au BufWritePost *cpp AsyncMake
au BufWritePost *cc  AsyncMake
au BufWritePost *h   AsyncMake

AsyncMake .

! , : P

0

AsyncCommand cgetfile , quickfix. , cgetfile QuickFixCmdPost. SetErrorMarkers() ( ). , ​​AsyncCommand. , , .

, , AsyncCommand. , github.

, AsyncCommand cgetfile. : autoload/asynchandler.vim 63 .

doautocmd User AsyncCommandQuickFixCmdPost

:

exe 'botright ' . self.mode . "open"
let cmd = self.command . ' ' . a:temp_file_name
exe cmd
doautocmd User AsyncCommandQuickFixCmdPost
if type(self.title) == type("") && self.title != ""

, :

augroup errormarker
    autocmd QuickFixCmdPost make call <SID>SetErrorMarkers()
    autocmd User AsyncCommandQuickFixCmdPost call <SID>SetErrorMarkers()
augroup END
+3

All Articles