Skip to content

Commit 61651ba

Browse files
committed
Use advice to allow focus instead of removing hook
1 parent 6400807 commit 61651ba

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

lsp-ui-doc.el

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ This only takes effect when `lsp-ui-doc-position' is 'top or 'bottom."
8787
(const :tag "Window" window))
8888
:group 'lsp-ui-doc)
8989

90+
(defcustom lsp-ui-doc-border "white"
91+
"Border color of the frame."
92+
:type 'color
93+
:group 'lsp-ui-doc)
94+
9095
(defcustom lsp-ui-doc-max-width 150
9196
"Maximum number of columns of the frame."
9297
:type 'integer
@@ -469,7 +474,10 @@ FN is the function to call on click."
469474
(url-hexify-string lsp-ui-doc--render-string))
470475
'lsp-ui-doc--webkit-resize-callback))
471476
(erase-buffer)
472-
(insert (s-trim lsp-ui-doc--render-string))
477+
(let ((inline-p (lsp-ui-doc--inline-p)))
478+
(insert (concat (unless inline-p (propertize "\n" 'face '(:height 0.2)))
479+
(s-trim lsp-ui-doc--render-string)
480+
(unless inline-p (propertize "\n\n" 'face '(:height 0.3))))))
473481
(lsp-ui-doc--make-clickable-link))
474482
(setq-local face-remapping-alist `((header-line lsp-ui-doc-header)))
475483
(setq-local window-min-height 1)
@@ -624,12 +632,14 @@ The structure of INFO is defined in the documentation of `posframe-show'."
624632
('(bottom window) #'posframe-poshandler-window-bottom-right-corner)
625633
('(at-point frame) #'lsp-ui-doc--posframe-poshandler-point-top-left-corner)
626634
('(at-point window) #'lsp-ui-doc--posframe-poshandler-point-top-left-corner)))
627-
(border-width (if lsp-ui-doc-use-webkit 0 8))
628635
(frame (posframe-show buffer
629636
:width lsp-ui-doc-max-width
630637
:height lsp-ui-doc-max-height
631638
:poshandler position
632-
:internal-border-width border-width
639+
:internal-border-width 1
640+
:internal-border-color lsp-ui-doc-border
641+
:left-fringe t
642+
:right-fringe t
633643
:background-color (face-background 'lsp-ui-doc-background nil t)
634644
:override-parameters params))
635645
(window (frame-root-window frame)))
@@ -762,12 +772,16 @@ before, or if the new window is the minibuffer."
762772
(push '(lsp-ui-doc-frame . :never) frameset-filter-alist)))
763773
(add-hook 'post-command-hook 'lsp-ui-doc--make-request nil t)
764774
(add-hook 'delete-frame-functions 'lsp-ui-doc--on-delete nil t)
765-
(remove-hook 'focus-in-hook 'posframe--redirect-posframe-focus t))
775+
(advice-add #'posframe--redirect-posframe-focus
776+
:before-until (lambda (&rest _)
777+
lsp-ui-doc-frame-mode)
778+
'((name . lsp-ui-doc--dont-redirect-posframe))))
766779
(t
767780
(lsp-ui-doc-hide)
768781
(remove-hook 'post-command-hook 'lsp-ui-doc--make-request t)
769782
(remove-hook 'delete-frame-functions 'lsp-ui-doc--on-delete t)
770-
(add-hook 'focus-in-hook 'posframe--redirect-posframe-focus nil t))))
783+
(advice-remove #'posframe--redirect-posframe-focus
784+
'lsp-ui-doc--dont-redirect-posframe))))
771785

772786
(defun lsp-ui-doc-enable (enable)
773787
"Enable/disable ‘lsp-ui-doc-mode’.
@@ -810,9 +824,7 @@ It is supposed to be called from `lsp-ui--toggle'"
810824
:init-value nil
811825
:lighter ""
812826
:group lsp-ui-doc
813-
:keymap `(([?q] . lsp-ui-doc-unfocus-frame))
814-
(when lsp-ui-doc-frame-mode
815-
(remove-hook 'focus-in-hook 'posframe--redirect-posframe-focus t)))
827+
:keymap `(([?q] . lsp-ui-doc-unfocus-frame)))
816828

817829
(defun lsp-ui-doc-focus-frame ()
818830
"Focus into lsp-ui-doc-frame."

0 commit comments

Comments
 (0)