@@ -662,7 +662,7 @@ FN is the function to call on click."
662
662
(when (< fill-column (length first-line))
663
663
(fill-region start (point-max ))))))
664
664
665
- (defun lsp-ui-doc--make-smaller-empty-lines nil
665
+ (defun lsp-ui-doc--make-smaller-empty-lines ()
666
666
" Make empty lines half normal lines."
667
667
(progn ; Customize line before header
668
668
(goto-char 1 )
@@ -682,7 +682,7 @@ FN is the function to call on click."
682
682
(forward-line ))
683
683
(insert (propertize " \n\n " 'face '(:height 0.3 ))))
684
684
685
- (defun lsp-ui-doc--fix-hr-props nil
685
+ (defun lsp-ui-doc--fix-hr-props ()
686
686
; ; We insert the right display prop after window-text-pixel-size
687
687
(lsp-ui-doc--with-buffer
688
688
(let (next)
@@ -767,7 +767,7 @@ FN is the function to call on click."
767
767
768
768
(defvar-local lsp-ui-doc--inline-width nil )
769
769
770
- (defun lsp-ui-doc--inline-window-width nil
770
+ (defun lsp-ui-doc--inline-window-width ()
771
771
(- (min (window-text-width ) (window-body-width ))
772
772
(if (bound-and-true-p display-line-numbers-mode)
773
773
(+ 2 (line-number-display-width ))
@@ -854,7 +854,7 @@ HEIGHT is the documentation number of lines."
854
854
(not (display-graphic-p ))
855
855
(not (fboundp 'display-buffer-in-child-frame ))))
856
856
857
- (defun lsp-ui-doc--highlight-hover nil
857
+ (defun lsp-ui-doc--highlight-hover ()
858
858
(when lsp-ui-doc--from-mouse-current
859
859
(-let* (((start . end) lsp-ui-doc--bounds)
860
860
(ov (if (overlayp lsp-ui-doc--highlight-ov) lsp-ui-doc--highlight-ov
@@ -930,9 +930,10 @@ HEIGHT is the documentation number of lines."
930
930
keyboard-quit
931
931
ignore
932
932
handle-switch-frame
933
- mwheel-scroll))
933
+ mwheel-scroll)
934
+ " List of command to ignore requests." )
934
935
935
- (defun lsp-ui-doc--make-request nil
936
+ (defun lsp-ui-doc--make-request ()
936
937
" Request the documentation to the LS."
937
938
(and (not track-mouse) lsp-ui-doc-show-with-mouse (setq-local track-mouse t ))
938
939
(when (and lsp-ui-doc-show-with-cursor
@@ -1094,9 +1095,18 @@ Argument WIN is current applying window."
1094
1095
:mode 'tick
1095
1096
:cancel-token :lsp-ui-doc-hover ))))))
1096
1097
1098
+ (defun lsp-ui-doc--tooltip-mouse-motion (event )
1099
+ " Default tooltip (EVENT) action."
1100
+ (interactive " e" )
1101
+ (tooltip-hide )
1102
+ (when (car (mouse-pixel-position ))
1103
+ (tooltip-start-delayed-tip )
1104
+ (setq tooltip-last-mouse-motion-event event)))
1105
+
1097
1106
(defun lsp-ui-doc--handle-mouse-movement (event )
1098
1107
" Show the documentation corresponding to the text under EVENT."
1099
1108
(interactive " e" )
1109
+ (lsp-ui-doc--tooltip-mouse-motion event)
1100
1110
(when lsp-ui-doc-show-with-mouse
1101
1111
(lsp-ui-util-safe-kill-timer lsp-ui-doc--timer-mouse-movement)
1102
1112
(let* ((e (cadr event))
@@ -1128,22 +1138,32 @@ Argument WIN is current applying window."
1128
1138
" Nil if `track-mouse' was set by another package.
1129
1139
If nil, do not prevent mouse on prefix keys." )
1130
1140
1131
- (defun lsp-ui-doc--setup-mouse nil
1132
- (when lsp-ui-doc-show-with-mouse
1141
+ (defvar lsp-ui-doc-mode-map
1142
+ (let ((map (make-sparse-keymap )))
1143
+ map)
1144
+ " Keymap for `lsp-ui-doc-mode' ." )
1145
+
1146
+ (defun lsp-ui-doc--setup-mouse ()
1147
+ " Setup mouse."
1148
+ (cond
1149
+ (lsp-ui-doc-show-with-mouse
1150
+ (define-key lsp-ui-doc-mode-map (kbd " <mouse-movement>" ) #'lsp-ui-doc--handle-mouse-movement )
1133
1151
(setq lsp-ui-doc--mouse-tracked-by-us (not track-mouse))
1134
1152
(setq-local track-mouse t )
1135
1153
(unless lsp-ui-doc--timer-mouse-idle
1136
1154
; ; Set only 1 timer for all buffers
1137
1155
(setq lsp-ui-doc--timer-mouse-idle
1138
- (run-with-idle-timer 0 t 'lsp-ui-doc--disable-mouse-on-prefix )))))
1156
+ (run-with-idle-timer 0 t 'lsp-ui-doc--disable-mouse-on-prefix ))))
1157
+ (t
1158
+ (define-key lsp-ui-doc-mode-map (kbd " <mouse-movement>" ) nil ))))
1139
1159
1140
1160
(defun lsp-ui-doc--prevent-focus-doc (e )
1141
1161
(not (frame-parameter (cadr e) 'lsp-ui-doc--no-focus )))
1142
1162
1143
1163
(define-minor-mode lsp-ui-doc-mode
1144
1164
" Minor mode for showing hover information in child frame."
1145
1165
:init-value nil
1146
- :keymap `((,( kbd " <mouse-movement> " ) . lsp-ui-doc--handle-mouse-movement))
1166
+ :keymap lsp-ui-doc-mode-map
1147
1167
:group lsp-ui-doc
1148
1168
(cond
1149
1169
(lsp-ui-doc-mode
0 commit comments