summaryrefslogtreecommitdiff
path: root/src/wasp-overlay.el
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-07-21 00:14:25 -0400
committerLLLL Colonq <llll@colonq>2026-07-21 00:14:25 -0400
commitf04ada478f4bfa5637744876f00ff56f85dcf552 (patch)
tree50cde49222fdddf4274b3e123568fe2c75c5e155 /src/wasp-overlay.el
parent75e005e81b73d8471f16dc5fad7bbdc312bdbfe7 (diff)
Update
Diffstat (limited to 'src/wasp-overlay.el')
-rw-r--r--src/wasp-overlay.el60
1 files changed, 51 insertions, 9 deletions
diff --git a/src/wasp-overlay.el b/src/wasp-overlay.el
index b62550e7..cc334f8a 100644
--- a/src/wasp-overlay.el
+++ b/src/wasp-overlay.el
@@ -48,6 +48,7 @@
(when-let* ((pos (window-absolute-pixel-position)))
(when (not (equal pos w/overlay-last-cursor))
(setf w/overlay-last-cursor pos)
+ (w/binary-pub "overlay asset clear" "")
(w/binary-pub "overlay info emacs cursor"
(s-concat
(w/bus-binary-build-length-prefixed (format "%s" (car pos)))
@@ -92,7 +93,7 @@ Optionally, make the cells be COLOR."
(defface w/overlay-clippy-face
'((t
:foreground "black"
- :font "Terminus (TTF):antialias=false:hinting=false:pixelsize=24"
+ :font "Terminus (TTF):antialias=false:hinting=false:pixelsize=12"
))
"Face for Clippy dialogue."
:group 'wasp)
@@ -158,17 +159,36 @@ Optionally, make the cells be COLOR."
(w/write-line msg 'w/overlay-clippy-face))))
(defun w/overlay-clippy-say (msg)
"Have Clippy say MSG."
- (w/overlay-clippy-clear)
- (w/overlay-clippy-write msg)
- (w/overlay-clippy-border t)
- (w/show-frame w/overlay-clippy-frame t)
- (raise-frame w/overlay-clippy-frame)
- (w/overlay-clippy-animate "EXPLAIN")
- (setf w/overlay-clippy-speech-timer 10))
+ (unless w/overlay-clippy-speech-timer
+ (w/overlay-clippy-clear)
+ (w/overlay-clippy-write msg)
+ (w/overlay-clippy-border t)
+ (w/show-frame w/overlay-clippy-frame t)
+ (raise-frame w/overlay-clippy-frame)
+ (w/overlay-clippy-animate "EXPLAIN")
+ (setf w/overlay-clippy-speech-timer 10)))
+(require 'flymake)
(defun w/overlay-clippy-check-events ()
"Check for events that Clippy should respond to."
- )
+ (when-let* ((diags (--filter (s-equals? "clippy" (flymake-diagnostic-origin it)) (flymake-diagnostics))))
+ (w/overlay-clippy-say
+ (s-concat
+ "It looks like you made a mistake.\nWould you like help with that?\n\n"
+ (s-join "\n"
+ (--map
+ (s-concat
+ (or
+ (-some->>
+ (flymake-diagnostic-data it)
+ (alist-get 'eglot-lsp-diag)
+ (w/plist-get :range)
+ (w/plist-get :start)
+ (w/plist-get :line)
+ (format "On line %s:\n"))
+ "")
+ (flymake-diagnostic-message it))
+ diags))))))
(defun w/overlay-clippy-update ()
"Update Clippy."
@@ -189,5 +209,27 @@ Optionally, make the cells be COLOR."
w/overlay-clippy-timer
(run-with-timer 1 nil #'w/overlay-clippy-timer-run)))
+(defun w/overlay-display-asset (type path)
+ "Indicate to the overlay that it should display an asset of TYPE at PATH."
+ (w/binary-pub "overlay asset display"
+ (s-concat
+ (w/bus-binary-build-length-prefixed type)
+ (w/bus-binary-build-length-prefixed path))))
+(defun w/overlay-asset-eldoc-display-function (docs interactive)
+ "Handler for `eldoc-display-functions' (DOCS INTERACTIVE)."
+ (ignore interactive)
+ (-each docs
+ (lambda (doc)
+ (when-let* ((docstr (format "%s" (car doc))))
+ (--each
+ (s-match-strings-all
+ (rx bol
+ "newton-" (group (one-or-more alnum)) ":" (zero-or-more space)
+ (group (one-or-more printing)) eol)
+ docstr)
+ (-when-let ((_ type path) it)
+ (w/overlay-display-asset type path)))))))
+(add-to-list 'eldoc-display-functions #'w/overlay-asset-eldoc-display-function)
+
(provide 'wasp-overlay)
;;; wasp-overlay.el ends here