Move flycheck back into init.el and add tooltip function

This commit is contained in:
Alexander Rosenberg 2024-03-05 08:48:55 -08:00
parent e1b2b36922
commit cfbc99e5d4
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
2 changed files with 50 additions and 46 deletions

View File

@ -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

64
init.el
View File

@ -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