From a189c211bf72aaa093289f5afb33763d2f36ecbd Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 30 Jun 2024 15:35:16 -0400 Subject: [PATCH] tweak(syntax): hide posframe on next user input Close: #7813 Ref: #6416 Co-authored-by: Dev380 --- modules/checkers/syntax/README.org | 3 +++ modules/checkers/syntax/config.el | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/modules/checkers/syntax/README.org b/modules/checkers/syntax/README.org index 5aa7ac8d8..80857885a 100644 --- a/modules/checkers/syntax/README.org +++ b/modules/checkers/syntax/README.org @@ -25,6 +25,9 @@ This module provides syntax checking and error highlighting, powered by ** Hacks - If ~lsp-ui-mode~ is active, most of the aesthetic functionality of this module is turned off, as they show the same information. +- If childframes are enabled, and the flycheck childframe is shown, it will be + hidden on the next user input (as well as the default behavior: to hide it the + next time the user is idle for ~flycheck-display-errors-delay~ seconds). ** TODO Changelog # This section will be machine generated. Don't edit it by hand. diff --git a/modules/checkers/syntax/config.el b/modules/checkers/syntax/config.el index a458d8768..5108ba7ee 100644 --- a/modules/checkers/syntax/config.el +++ b/modules/checkers/syntax/config.el @@ -74,6 +74,21 @@ (setq flycheck-posframe-warning-prefix "! " flycheck-posframe-info-prefix "ยทยทยท " flycheck-posframe-error-prefix "X ") + + ;; HACK: Hide the flycheck posframe immediately on the next keypress/user + ;; action, otherwise it lingers until the next time the user is idle. + (defun +syntax--flycheck-posframe-hide-h () + (unless (flycheck-posframe-check-position) + (posframe-hide flycheck-posframe-buffer)) + (remove-hook 'post-command-hook #'+syntax--flycheck-posframe-hide-h)) + + (defadvice! +syntax-hide-posframe-on-next-command-a (fn &rest args) + :around #'flycheck-posframe-show-posframe + (letf! ((defun posframe-show (&rest args) + (add-hook 'post-command-hook #'+syntax--flycheck-posframe-hide-h) + (apply posframe-show args))) + (apply fn args))) + (after! company ;; Don't display popups if company is open (add-hook 'flycheck-posframe-inhibit-functions #'company--active-p))