diff --git a/disabled.el b/disabled.el index e12940f..9a151da 100644 --- a/disabled.el +++ b/disabled.el @@ -47,38 +47,6 @@ ;; (fido-mode 1) ;; (fido-vertical-mode 1)) -;; flycheck -;; (use-package flycheck -;; :hook (emacs-lisp-mode . flycheck-mode) -;; :bind (:map flycheck-mode-map -;; ("C-c e" . my/flycheck-show-diagnostic-at-point)) -;; :init -;; (setq flycheck-display-errors-function nil) -;; (defun my/flycheck-show-diagnostic-at-point () -;; (interactive) -;; (if-let ((flycheck-mode) -;; (errors (flycheck-overlay-errors-at (point))) -;; (message (apply 'concat -;; (mapcar -;; (lambda (error) -;; (concat "•" (flycheck-error-message error) "\n")) -;; errors)))) -;; (if (display-graphic-p) -;; (progn -;; (posframe-show " *flycheck-error-posframe*" -;; :string message -;; :position (point) -;; :max-width 80 -;; :border-width 2 -;; :border-color "white") -;; (clear-this-command-keys) -;; (push (read-event) unread-command-events) -;; (posframe-hide " *flycheck-error-posframe*")) -;; (popup-tip message))))) -;; (use-package consult-flycheck -;; :bind (:map flycheck-mode-map -;; ("C-c C-e" . consult-flycheck))) - ;; lsp-mode ;; (use-package consult-lsp) ;; (use-package lsp-mode diff --git a/init.el b/init.el index 1f185b3..535a42b 100644 --- a/init.el +++ b/init.el @@ -414,14 +414,39 @@ visual states." (use-package popup) ;; posframe -(use-package posframe) +(use-package posframe + :init + (defun my/posframe-tip (name msg) + "Like `popup-tip', but with a posframe. +NAME should be the buffer name to pass to `posframe-show'. MSG is the message to +display." + (unwind-protect + (progn + (posframe-show name + :string msg + :position (point) + :max-width 80 + :border-width 2 + :border-color "white") + (clear-this-command-keys) + (push (read-event) unread-command-events) + (posframe-hide name)) + (posframe-hide name)))) + +(defun my/floating-tooltip (name msg) + "If `display-graphic-p', call `my/posframe-tip', otherwise `popup-tip'. +MSG is the message to show in the popup. NAME is the name of the buffer to pass +to `posframe-show' if the display is graphical." + (if (display-graphic-p) + (my/posframe-tip name msg) + (popup-tip msg))) ;; flymake (use-package flymake :bind (:map flymake-mode-map ("C-c e" . my/flymake-show-diagnostic-at-point) ("C-c C-e" . consult-flymake)) - :hook (emacs-lisp-mode . flymake-mode) + ;; :hook (emacs-lisp-mode . flymake-mode) :init (defun my/flymake-show-diagnostic-at-point () (interactive) @@ -429,18 +454,29 @@ visual states." (diag (and flymake-mode (get-char-property pos 'flymake-diagnostic))) (message (flymake--diag-text diag))) - (if (display-graphic-p) - (progn - (posframe-show " *flymake-error-posframe*" - :string message - :position (point) - :max-width 80 - :border-width 2 - :border-color "white") - (clear-this-command-keys) - (push (read-event) unread-command-events) - (posframe-hide " *flymake-error-posframe*")) - (popup-tip message))))) + (my/floating-tooltip " *flymake-error-posframe*" message)))) + +;; flycheck +(use-package flycheck + :hook (emacs-lisp-mode . flycheck-mode) + :bind (:map flycheck-mode-map + ("C-c e" . my/flycheck-show-diagnostic-at-point)) + :init + (setq flycheck-display-errors-function nil) + (defun my/flycheck-show-diagnostic-at-point () + (interactive) + (if-let ((flycheck-mode) + (errors (flycheck-overlay-errors-at (point))) + (message (apply 'concat + (mapcar + (lambda (error) + (concat "•" (flycheck-error-message error) "\n")) + errors)))) + (my/floating-tooltip " *flycheck-error-posframe*" + (substring message 0 (1- (length message))))))) +(use-package consult-flycheck + :bind (:map flycheck-mode-map + ("C-c C-e" . consult-flycheck))) ;; eldoc (use-package eldoc