开发者

Silent make execution in vim/gvim

I want to use gvim to launch make开发者_运维百科 and do the build for my code. Since the build process takes some time i want it to be silently executed and then in the end errors/build log be showed to me.

i have added this to my .vimrc

:command -nargs=* Make silent make <args>  | cwindow 10
map <c-b> <c-o>:Make<cr>

So when i press Ctrl-b it starts building. But when i do that my gvim hangs and i cant do anything for sometime. Is there a way to accomplish what i am trying to do.

Since i am using cwindow 10 at the end of make , it launches the quickfix window. In addition to that i also want to see the build log. Can i somehow do that


As I said in similar questions: Have a look at my AsyncCommand plugin. Add the script to your .vim/plugin and you can build with :AsyncMake or :AsyncMake target. Errors will be opened in your quickfix once the make completes.


For the log file, you could extend AsyncMake to also open the build log. Add this to your vimrc after you've installed asynccommand.vim:

function! AsyncMakeWithLog(target)
    let make_cmd = &makeprg ." ". a:target
    let vim_func = "OnCompleteLoadErrorAndLog"
    call AsyncCommand(make_cmd, vim_func)
endfunction
" Load the output as an error file and load the full build log
function! OnCompleteLoadErrorAndLog(temp_file_name)
    call OnCompleteLoadErrorFile(a:temp_file_name)
    call OnCompleteLoadFile(a:temp_file_name)
endfunction

However, the log file and the error window will have a lot of the same text, so you don't always need both. If your build tool already writes its build log to disk, then I'd suggest you have the build output include the full path to the build log. That way you can type gf on the path in the error window to jump to the build log when necessary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜