Tuesday, May 12, 2020

changing pathnames in quickfix list

I have a Makefile rule that builds some go packages in a directory a few levels
down from the current directory:

cd down/down/down && $(GO) build $(GO_BUILD_FLAGS) -o ../../../../$(@) $*

When I run :make, it builds as expected, but if I have an error, then I get
something like

# dir1/dir2/pkg
dir2/pkg/foo.go:53:16: undefined: "github.com/pkg/errors".Wrrapf

The quickfix list loads "dir2/pkg/foo.go", which doesn't exist: the file is
actually at "down/down/down/dir2/pkg/foo.go".

Is there a way to get the right information into the quickfix list?

I tried adding "%Dcd\ %f\ " to 'errorformat', relying on the "missing leave
directory" heuristics to figure the rest out, but that didn't seem to work.

I could write a function for QuickFixCmdPost that would look at each buffer,
grab its name, and if the name didn't exist, load the real file into a buffer,
change the list, and wipeout the incorrect buffer, but a) it's a lot of work,
and b) we end up loading a lot of buffers for bogus files.

I feel like there's got to be a way to intercept the quickfix list before vim
has parsed it, or at least before it's created buffers for the files with
errors. Is there? Should there be?

Thanks,
Danek

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200512160257.GC9948%40comfychair.org.

No comments: