I'm diving into the quickfix list of Vim that looks quite awesome, however I am not being able to exploit this because of a relative path problem. Explanation:
My Vim window path is .
I have a custom make command in Vim:
:set makeprg=west\ build\ -b\ nucleo_l552ze_q\ .\
The west program will use CMake and gcc to compile my project. But here is the thing: it changes the current directory to ./build.
So, in Vim, when I run
:make
the quickfix list is filled with references like ../src/main.c instead of src/main.c
As a result, when I try to open a file from the quickfix list, Vim creates a new file using make
's relative path instead of opening the file I wanted based on the Vim working directory.
My question is: How do I open :make entries that were compiled in different directory than the vim working directory?
Is it possible to change the root path of the quickfix list after running the make command ?
This vimscript file allows you to open the current entry in the quickfix window in a new tab, complete with substituting the
make
path with thevim
path.Create a file with exactly this path
~/.vim/after/ftplugin/qf.vim
, then put this in the file:The file path means this script will load in
after
the default qf files and theftplugin
means this stuff only modifies the quickfix filetype. This can be modified to open new windows, splits, and use different hotkeys if desired. This substitution will only work if the build path of make is always in the same location.