Question

I have a C++ project which I compile using ninja and clang++, and would like to have errors during compilation appear in the quickfix list. Currently, when I set makeprg=ninja, and then run :make, all of the output generated by ninja simply appears in the quickfix window, and cannot be used to jump to the corresponding files/lines etc.

I am NOT looking for the functionality given by syntastic (which I am already using), but I also want to see errors from other files in the project, similar to what IDEs provide.

If this cannot (easily) be done with ninja, solutions using make are also welcome(the project uses cmake, so both are possible), but I would like to stay with ninja, if possible.

Was it helpful?

Solution

all of the output generated by ninja simply appears in the quickfix window, and cannot be used to jump

That sounds like Vim cannot parse the location information out of the errors because the appropriate 'errorformat' hasn't been set.

Search around, maybe someone has already written such. Otherwise, you need to write your own compiler plugin, and then use :compiler ninja instead of :set makeprg=ninja. See :help write-compiler-plugin.

OTHER TIPS

CMake+Ninja uses relative path. This is a problem in Vim. Vim uses an algorithm to try and guess the location of the files where an error was raised. You can find a description of the latter at :h quickfix-directory-stack. Also, please look here: https://gitlab.kitware.com/cmake/cmake/-/issues/13894. CMake people are aware of this and have an open issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top