From 8dba697a2c9e3b5c9f0fcb45e155adb6243ad609 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Wed, 22 Dec 2021 07:39:02 +0000
Subject: [PATCH] Help flycheck find project root
---
config.org | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/config.org b/config.org
index 938742e..ed49c9e 100644
--- a/config.org
+++ b/config.org
@@ -960,7 +960,8 @@
** Language specific configs
*** C/C++
-**** Flycheck clang
+**** Flycheck
+***** Flycheck clang
Add the clang backend for linting.
#+BEGIN_SRC emacs-lisp
(use-package flycheck-clang-analyzer
@@ -971,6 +972,23 @@
(require 'flycheck-clang-analyzer)
(flycheck-clang-analyzer-setup)))
#+END_SRC
+***** Flycheck project root
+Flycheck tends to fail finding the project root, giving errors about missing files.
+This should remove them.
+#+BEGIN_SRC emacs-lisp
+ (defun setup-flycheck-project-path ()
+ (let ((root (ignore-errors (projectile-project-root))))
+ (when root
+ (add-to-list
+ (make-variable-buffer-local 'flycheck-clang-include-path)
+ root)
+ (add-to-list
+ (make-variable-buffer-local 'flycheck-gcc-include-path)
+ root))))
+
+ (add-hook 'c-mode-hook 'setup-flycheck-project-path)
+ (add-hook 'c++-mode-hook 'setup-flycheck-project-path)
+#+END_SRC
**** COMMENT Company
Add header completion as well as Irony, which uses clang for suggestions.
--
Gitblit v1.10.0