Import build errors into vim w/ jump-to-file support
dbarnett opened this issue · comments
If a :Bazel build
command fails, users should be able to browse the individual error messages from within vim and jump to the referenced file locations via something like the quickfix list.
Note that actually processing bazel output and extracting file location information from any given message will be surprisingly complex. We may want a helper tool to that we can pipe bazel's output to parse log output, handling the idiosyncracies of different kinds of tool output and converting them to a single machine-readable format.
@martindemello has worked on processing bazel output and might be able to help out here.
Discussed w/ @Kashomon, he suggests quickfix isn't the right paradigm at all and we should consider presenting the full build log w/ annotations so we can support jumping straight to referenced file locations, highlight error messages to stand out, etc. Advantages:
- Full tool output is usually a lot more readable than extracted error messages, containing more context in related messages before/after the error.
- Less finicky to configure and doesn't break down in some pathological cases that are hard to ingest cleanly.
- Don't have to do complicated post-processing on bazel's output to squash multi-line errors into one line.
I already suspected quickfix had some technical limitations we wouldn't want to be stuck with, but I'm thinking Josh is right that we shouldn't even be trying to emulate the quickfix UI necessarily. Here's the model I have in mind:
- Builds that have an exit code open a split pane showing bazel's output (with a command like
:BazelOutput
to view this same output pane on demand when there's not an exit code). - Highlights error/warning messages, file locations, and other annotations in the output. We'll need some regex configuration to process different error message formats for this.
- Shortcut key to jump to file locations under the cursor (Enter or Ctrl-]?)
- Supports quick actions to hide info so long logs are easier to read, w/ user setting for whether to hide these by default. Should show a marker wherever lines are hidden, possibly using vim's built-in folding support for intuitive manipulation.
Is this issue being worked on or is there a workaround?
No work started. Just have to grab filenames from the command output and :edit
them manually in the meantime.
Unfortunate, but thanks for responding quickly.
This would be awesome. If someone were to add this, would it integrate with BEP? It could be useful to show the labels of what failed too I think
I just submitted a pull request that adds this feature using vim's built in quickfix. I see that there has been some discussion of the limitations of vim's error parser, however, at least in my own use, I haven't found any problems with it.
@matawed asked for my code that does this, but I don't think it is what is being talked about here.
I have a server that implements the BES and writes a file in a format that works with vims quickfix window.
https://github.com/endobson/bes-server/blob/master/bes_server.cc
@endobson thanks for the project link. Can you provide a newbie instructions on how to use the bes_server with a build to extract error output ?
It doesn't work for any project but mine as it is very sensitive to the error format/project layout.
You run the server, point bazel at it via the --bes_backend=localhost:8089
flag and it writes files for vim at a specific path (https://github.com/endobson/bes-server/blob/ac9699210f15f8787c4e3d941d740eda4673f1ee/bes_server.cc#L115). You also need to setup bazel for remote caching so that it can access the outputs.
From there you have a file that vim's quickfix just works with.