使用射弹在 .dir-locals 中设置 flycheck-clang-include-path
Setting flycheck-clang-include-path in .dir-locals using projectile
尝试设置 flycheck-clang-include-path 而无需包括项目的完整路径包括使用 projectile 的目录,但我收到错误...所以这有效:
((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"
))
)))
但这不是:
((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")
))
)))
报告的错误:
flycheck-substitute-argument: Value ((concat (projectile-project-root) "headers")) of flycheck-clang-include-path for option "-I" is not a list of strings
一种可能性是使用 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")))))))
尝试设置 flycheck-clang-include-path 而无需包括项目的完整路径包括使用 projectile 的目录,但我收到错误...所以这有效:
((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"
))
)))
但这不是:
((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")
))
)))
报告的错误:
flycheck-substitute-argument: Value ((concat (projectile-project-root) "headers")) of flycheck-clang-include-path for option "-I" is not a list of strings
一种可能性是使用 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")))))))