vim-bazel icon indicating copy to clipboard operation
vim-bazel copied to clipboard

Import build errors into vim w/ jump-to-file support

Open dbarnett opened this issue 8 years ago • 10 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.

dbarnett avatar Dec 15 '16 01:12 dbarnett

@martindemello has worked on processing bazel output and might be able to help out here.

dbarnett avatar Dec 15 '16 01:12 dbarnett

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.

dbarnett avatar Jan 22 '17 19:01 dbarnett

Is this issue being worked on or is there a workaround?

ptarjan avatar Oct 13 '17 23:10 ptarjan

No work started. Just have to grab filenames from the command output and :edit them manually in the meantime.

dbarnett avatar Oct 14 '17 23:10 dbarnett

Unfortunate, but thanks for responding quickly.

ptarjan avatar Oct 14 '17 23:10 ptarjan

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

jerrymarino avatar Nov 17 '17 21:11 jerrymarino

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.

davisking avatar Oct 21 '18 16:10 davisking

@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 avatar Feb 12 '20 01:02 endobson

@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 ?

mellery451 avatar Mar 11 '20 21:03 mellery451

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.

endobson avatar Mar 11 '20 22:03 endobson