@@ -163,6 +163,8 @@ It is used to know when the window has changed of width.")
163
163
This face have a low priority over the others."
164
164
:group 'lsp-ui-sideline )
165
165
166
+ (defvar lsp-ui-resources-dir )
167
+
166
168
(defun lsp-ui-sideline--first-line-p (pos )
167
169
" Return non-nil if POS is on the first line."
168
170
(save-excursion
@@ -402,6 +404,22 @@ Push sideline overlays on `lsp-ui-sideline--ovs'."
402
404
(user-error " No code actions on the current line" ))
403
405
(lsp-execute-code-action (lsp--select-action lsp-ui-sideline--code-actions)))
404
406
407
+ (defun lsp-ui-sideline--scale-lightbulb nil
408
+ (--> (frame-char-height )
409
+ ; ; 128 is the height in pixel of lightbulb.png
410
+ (/ (float it) 128 )))
411
+
412
+ (defvar lsp-ui-sideline--image-lightbulb
413
+ (and lsp-ui-resources-dir
414
+ (image-type-available-p 'png )
415
+ `(image :type png :file ,(expand-file-name " lightbulb.png" lsp-ui-resources-dir) :ascent center)))
416
+
417
+ (defun lsp-ui-sideline--code-actions-image nil
418
+ (when lsp-ui-sideline--image-lightbulb
419
+ (concat
420
+ (propertize " " 'display (append lsp-ui-sideline--image-lightbulb `(:scale ,(lsp-ui-sideline--scale-lightbulb))))
421
+ (propertize " " 'display '(space :width 0.3 )))))
422
+
405
423
(defun lsp-ui-sideline--code-actions (actions bol eol )
406
424
" Show code ACTIONS."
407
425
(when lsp-ui-sideline-actions-kind-regex
@@ -418,7 +436,9 @@ Push sideline overlays on `lsp-ui-sideline--ovs'."
418
436
(seq-doseq (action actions)
419
437
(-let* ((title (->> (lsp:code-action-title action)
420
438
(replace-regexp-in-string " [\n\t ]+" " " )
421
- (concat lsp-ui-sideline-code-actions-prefix)))
439
+ (concat (unless lsp-ui-sideline--image-lightbulb
440
+ lsp-ui-sideline-code-actions-prefix))))
441
+ (image (lsp-ui-sideline--code-actions-image))
422
442
(margin (lsp-ui-sideline--margin-width))
423
443
(keymap (let ((map (make-sparse-keymap )))
424
444
(define-key map [down-mouse-1] (lambda () (interactive )
@@ -430,9 +450,10 @@ Push sideline overlays on `lsp-ui-sideline--ovs'."
430
450
(add-face-text-property 0 len 'lsp-ui-sideline-code-action nil title)
431
451
(add-text-properties 0 len `(keymap , keymap mouse-face highlight ) title)
432
452
title))
433
- (string (concat (propertize " " 'display `(space :align-to (- right-fringe ,(lsp-ui-sideline--align len margin))))
453
+ (string (concat (propertize " " 'display `(space :align-to (- right-fringe ,(lsp-ui-sideline--align (+ len (length image)) margin))))
454
+ image
434
455
(propertize title 'display (lsp-ui-sideline--compute-height))))
435
- (pos-ov (lsp-ui-sideline--find-line (1+ (length title)) bol eol t ))
456
+ (pos-ov (lsp-ui-sideline--find-line (+ 1 (length title) ( length image )) bol eol t ))
436
457
(ov (and pos-ov (make-overlay (car pos-ov) (car pos-ov)))))
437
458
(when pos-ov
438
459
(overlay-put ov 'after-string string)
0 commit comments