Emacs: Don't install flycheck-clang-tidy if clangd >= 9 is present.

This commit is contained in:
tastytea 2020-03-27 13:52:56 +01:00
parent b781e73961
commit d725fab455
1 changed files with 32 additions and 33 deletions

View File

@ -1,6 +1,6 @@
;;; c++.el --- C++ settings. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-03-27T13:46:19+0100>
;; Time-stamp: <2020-03-27T13:52:06+0100>
;;; Commentary:
@ -11,38 +11,37 @@
(require 'programming/common)
(unless slow-computer
(use-package flycheck-clang-tidy
;; :pin melpa
:after (flycheck projectile lsp-ui)
:if (executable-find "clang-tidy")
;; clang-tidy is built into clangd >= 9.
:if (< (my/clangd-version) 9.0)
:config
(defun my/clang-tidy-off ()
"Disable c/c++-clang-tidy."
(when (or (eq major-mode 'c++-mode) (eq major-mode 'c-mode))
(add-to-list 'flycheck-disabled-checkers 'c/c++-clang-tidy))
)
(defun my/clang-tidy-on ()
"Enable c/c++-clang-tidy."
(when (or (eq major-mode 'c++-mode) (eq major-mode 'c-mode))
(setq-local flycheck-disabled-checkers
(remove 'c/c++-clang-tidy flycheck-disabled-checkers)))
)
(defun my/flycheck-clang-tidy-setup ()
(flycheck-clang-tidy-setup)
;; Run clang-tidy after the lsp-ui checker.
(when lsp-mode
(unless (equal (flycheck-get-next-checker-for-buffer 'lsp-ui)
'c/c++-clang-tidy)
(flycheck-add-next-checker 'lsp-ui '(warning . c/c++-clang-tidy)))))
:hook
(flycheck-mode . my/flycheck-clang-tidy-setup)
(first-change . my/clang-tidy-off) ; Disable when file is modified.
(before-save . my/clang-tidy-on) ; Enable if file is saved.
)
(when (and (executable-find "clang-tidy")
;; clang-tidy is built into clangd >= 9.
(< (my/clangd-version) 9.0))
(use-package flycheck-clang-tidy
:after (flycheck projectile lsp-ui)
:defines (lsp-mode)
:config (progn
(defun my/clang-tidy-off ()
"Disable c/c++-clang-tidy."
(when (or (eq major-mode 'c++-mode)
(eq major-mode 'c-mode))
(add-to-list 'flycheck-disabled-checkers
'c/c++-clang-tidy)))
(defun my/clang-tidy-on ()
"Enable c/c++-clang-tidy."
(when (or (eq major-mode 'c++-mode)
(eq major-mode 'c-mode))
(setq-local flycheck-disabled-checkers
(remove 'c/c++-clang-tidy
flycheck-disabled-checkers))))
(defun my/flycheck-clang-tidy-setup ()
(flycheck-clang-tidy-setup)
;; Run clang-tidy after the lsp-ui checker.
(when lsp-mode
(unless (equal (flycheck-get-next-checker-for-buffer
'lsp-ui) 'c/c++-clang-tidy)
(flycheck-add-next-checker
'lsp-ui '(warning . c/c++-clang-tidy))))))
:hook ((flycheck-mode . my/flycheck-clang-tidy-setup)
(first-change . my/clang-tidy-off) ; Disable when file is modified.
(before-save . my/clang-tidy-on)))) ; Enable if file is saved.
) ; unless slow-computer.
;; Highlight Doxygen comments.