emacs-flymake icon indicating copy to clipboard operation
emacs-flymake copied to clipboard

Setting project include dirs is painful

Open ruffianeo opened this issue 3 years ago • 0 comments

Documentation is sparse. It implies, from what is written there, that I could do something like this:

(defun my-project-dirs (basedir)
  (mapcar #'(lambda (r) (expand-file-name (concat (expand-file-name basedir) "/" r)))
          '("." "..")))
(setq flymake-proc-get-project-include-dirs-function #'my-project-dirs)

Doing that in *scratch* buffer does not change the fact, that my

#include <args.hpp> // resides in BASEDIR/..

Is still not recognized.

Then there are the ways, not mentioned in above documentation (some project local .el file with an eval statement) and whatever else google yields on the subject.

I am aware, I could write #include "../args.hpp" instead, but in my reality, project file locations have nothing to do in c++ source files. It is a configuration matter, not code.

Then there is the cryptic

The default implementation, flymake-proc-get-project-include-dirs-imp, uses a make call.

which says nothing about any requirements for the makefile. Looking at source code of flymake, it seems to look for something like INCLUDE_DIRS. So, in my Makefile, I wrote:

INCLUDE_DIRS = . ..

But that still does not yield the correct result. And even if it worked, it is but a half-baked solution, because the Makefile could build multiple targets with different include directories for each of them.

Since using language servers (lsp-mode) is quite common today, maybe there is a convenient solution for flymake to make use of that infrastructure to find out, which project include directories are required.

ruffianeo avatar Nov 17 '22 13:11 ruffianeo