在 vim/gvim 中静默执行 make

发布于 2024-08-24 11:52:58 字数 394 浏览 4 评论 0原文

我想使用 gvim 启动 make 并为我的代码进行构建。由于构建过程需要一些时间,我希望它以静默方式执行,然后最终向我显示错误/构建日志。

我已将其添加到我的 .vimrc 中

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

,因此当我按 Ctrl-b 时,它就开始构建。但是当我这样做时,我的 gvim 挂起,有时我什么也做不了。有没有办法完成我想做的事情。

由于我在 make 末尾使用 cwindow 10 ,因此它会启动快速修复窗口。除此之外我还想查看构建日志。我可以这样做吗

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹤舞 2024-08-31 11:52:58

正如我在类似问题中所说:看看我的 AsyncCommand 插件。将脚本添加到您的 .vim/plugin 中,您可以使用 :AsyncMake:AsyncMake target 进行构建。一旦 make 完成,错误将在您的快速修复中打开。


对于日志文件,您可以扩展 AsyncMake 以打开构建日志。安装 asynccommand.vim 后,将其添加到您的 vimrc 中:

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

但是,日志文件和错误窗口将有很多相同的文本,因此您并不总是需要两者。如果您的构建工具已经将其构建日志写入磁盘,那么我建议您让构建输出包含构建日志的完整路径。这样您就可以在错误窗口中的路径上输入 gf 来在必要时跳转到构建日志。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文