SFbay007
SFbay007

Reputation: 2027

Setting flycheck-clang-include-path in .dir-locals using projectile

Trying to set flycheck-clang-include-path without the need to include the full path of the project include directories using projectile, but I get errors... So this works:

((nil . (
     (company-clang-arguments . (
                     "/home/user/Downloads/project/headers"
                     "/home/user/Downloads/project/source/mon"
                     ))
         (flycheck-clang-include-path . (
                     "/home/user/Downloads/project/headers"
                     "/home/user/Downloads/project/source/mon"
                     ))
     )))

But this does not:

((nil . (
     (company-clang-arguments . (
                     (concat "-I" (projectile-project-root) "headers")
                     (concat "-I" (projectile-project-root) "source/mon")
                     ))
         (flycheck-clang-include-path . (
                     (concat (projectile-project-root) "headers")
                     (concat (projectile-project-root) "source/mon")
                     ))
     )))

The error that is reported:

flycheck-substitute-argument: Value ((concat (projectile-project-root) "headers")) of flycheck-clang-include-path for option "-I" is not a list of strings

Upvotes: 2

Views: 2545

Answers (1)

Rorschach
Rorschach

Reputation: 32426

One possibility is using an eval to evaluate the quoted forms in your dir-locals. This may be considered unsafe since anything could be evaluated in such a form.

((nil 
  (eval . (let ((root (projectile-project-root)))
            (setq-local company-clang-arguments
                        (list (concat "-I" root "headers")
                              (concat "-I" root "source/mon")))
            (setq-local flycheck-clang-include-path
                        (list (concat root "headers")
                              (concat root "source/mon")))))))

Upvotes: 3

Related Questions