diff --git a/modules/tools/flycheck/autoload.el b/modules/tools/flycheck/autoload.el index bfc65a51f..cc8167c4e 100644 --- a/modules/tools/flycheck/autoload.el +++ b/modules/tools/flycheck/autoload.el @@ -1,24 +1,13 @@ ;;; tools/flycheck/autoload.el -*- lexical-binding: t; -*- ;;;###autoload -(defun +flycheck*popup-tip-delete-popup (orig-fn) - "TODO" - (when (display-graphic-p) - (funcall orig-fn))) - -;;;###autoload -(defun +flycheck*popup-tip-show-popup (orig-fn errors) - "TODO" - (if (and EMACS26+ - (featurep 'flycheck-posframe) - (display-graphic-p)) - (flycheck-posframe-show-posframe errors) - (funcall orig-fn errors))) - -;;;###autoload -(defun +flycheck|disable-popup-tip-for-lsp () - "Disable `+flycheck-popup-mode' if `lsp-ui-mode' and `lsp-ui-sideline-enable' -are non-nil." - (when (and (bound-and-true-p lsp-ui-mode) - lsp-ui-sideline-enable) - (flycheck-popup-tip-mode -1))) +(defun +flycheck|init-popups () + "Activate `flycheck-posframe-mode' if available and in GUI Emacs. +Activate `flycheck-popup-tip-mode' otherwise. +Do nothing if `lsp-ui-mode' is active and `lsp-ui-sideline-enable' is non-nil." + (unless (and (bound-and-true-p lsp-ui-mode) + lsp-ui-sideline-enable) + (if (and (fboundp 'flycheck-posframe-mode) + (display-graphic-p)) + (flycheck-posframe-mode +1) + (flycheck-popup-tip-mode +1)))) diff --git a/modules/tools/flycheck/config.el b/modules/tools/flycheck/config.el index c3983261a..9aab8aef1 100644 --- a/modules/tools/flycheck/config.el +++ b/modules/tools/flycheck/config.el @@ -32,19 +32,13 @@ (def-package! flycheck-popup-tip :commands (flycheck-popup-tip-show-popup flycheck-popup-tip-delete-popup) - :hook (flycheck-mode . flycheck-popup-tip-mode) - :init (add-hook 'lsp-ui-mode-hook #'+flycheck|disable-popup-tip-for-lsp) - :config - (setq flycheck-popup-tip-error-prefix "✕ ") - ;; Allow `flycheck-posframe' or `flycheck-popup-tip' to co-exist - ;; interchangibly, depending on the display device (terminal or GUI Emacs). - (advice-add #'flycheck-popup-tip-show-popup :around #'+flycheck*popup-tip-show-popup) - (advice-add #'flycheck-popup-tip-delete-popup :around #'+flycheck*popup-tip-delete-popup)) + :init (add-hook 'flycheck-mode-hook #'+flycheck|init-popups) + :config (setq flycheck-popup-tip-error-prefix "✕ ")) (def-package! flycheck-posframe :when (and EMACS26+ (featurep! +childframe)) - :commands flycheck-posframe-show-posframe + :init (add-hook 'flycheck-mode-hook #'+flycheck|init-popups) :config (setq flycheck-posframe-warning-prefix "⚠ " flycheck-posframe-info-prefix "··· "