使用射弹在.dir-locals中设置flycheck-clang-include-path [英] Setting flycheck-clang-include-path in .dir-locals using projectile

查看:150
本文介绍了使用射弹在.dir-locals中设置flycheck-clang-include-path的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用flyile设置flycheck-clang-include-path而不需要包含项目的完整路径(包括目录),但是我遇到了错误...因此可行:

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"
                     ))
     )))

但这不是:

((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中带引号的形式.这可能被认为是不安全的,因为任何事情都可以用这种形式进行评估.

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")))))))

这篇关于使用射弹在.dir-locals中设置flycheck-clang-include-path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆