From d725fab4550a6fa6580bea519feebcf9bc71bdc3 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 27 Mar 2020 13:52:56 +0100 Subject: [PATCH] Emacs: Don't install flycheck-clang-tidy if clangd >= 9 is present. --- init.d/programming/c++.el | 65 +++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/init.d/programming/c++.el b/init.d/programming/c++.el index cd55a8b..e391e34 100644 --- a/init.d/programming/c++.el +++ b/init.d/programming/c++.el @@ -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.