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

View File

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