2

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
4

1 回答 1

3

一种可能性是使用eval评估您的dir-locals. 这可能被认为是不安全的,因为任何东西都可以以这种形式进行评估。

((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")))))))
于 2017-06-04T19:25:25.417 回答