@@ -148,7 +148,6 @@ They are added to `markdown-code-lang-modes'")
148148The functions receive 2 parameters: the frame and its window."  )
149149
150150(defvar-local  lsp-ui-doc--bounds nil )
151- (defvar-local  lsp-ui-doc--string-eldoc nil )
152151
153152(declare-function  lsp-ui-sideline--get-renderer 'lsp-ui-sideline )
154153
@@ -194,17 +193,6 @@ Because some variables are buffer local.")
194193              (frame-parameter  nil  'name ))
195194          " *" 
196195
197- (defun  lsp-ui-doc--set-eldoc  (marked-string )
198-   (when  marked-string
199-     (let  ((string  (lsp-ui-doc--extract-marked-string marked-string)))
200-       (setq  lsp-ui-doc--string-eldoc string))))
201- 
202- (defun  lsp-ui-doc--eldoc  (&rest  _ )
203-   (when  (and  (lsp--capability " documentHighlightProvider" 
204-              lsp-highlight-symbol-at-point)
205-     (lsp-symbol-highlight))
206-   lsp-ui-doc--string-eldoc)
207- 
208196; ; ‘markdown-fontify-code-block-default-mode’ isn’t yet available in
209197; ; Markdown 2.3.
210198(defvar  markdown-fontify-code-block-default-mode )
@@ -268,7 +256,9 @@ MODE is the mode used in the parent frame."
268256  (let  ((groups (--separate (and  (hash-table-p  it)
269257                                 (lsp-ui-sideline--get-renderer (gethash  " language" 
270258                            (append  list-marked-string nil ))))
271-     (lsp-ui-doc--set-eldoc (caar  groups))
259+     (when-let  ((marked-string (caar  groups)))
260+       ; ; Without run-with-idle-timer, echo area will be cleared after displaying the message instantly.
261+       (run-with-idle-timer  0  nil  (lambda  () (eldoc-message  (lsp-ui-doc--extract-marked-string marked-string)))))
272262    (if  lsp-ui-doc-include-signature
273263        list-marked-string
274264      (cadr  groups))))
@@ -291,27 +281,30 @@ We don't extract the string that `lps-line' is already displaying."
291281     ((gethash  " language" ; ; MarkedString
292282      (lsp-ui-doc--extract-marked-string contents)))))
293283
294- (defun  lsp-ui-doc--make-request   ( )
284+ (defun  lsp-ui-doc--hover   ( orig-fn )
295285  " Request the documentation to the LS." 
296-   (when  (and  (bound-and-true-p  lsp--cur-workspace)
297-              (not  (bound-and-true-p  lsp-ui-peek-mode))
298-              (lsp--capability " hoverProvider" 
299-     (cond 
300-      ((symbol-at-point )
301-       (let  ((bounds (bounds-of-thing-at-point  'symbol )))
302-         (unless  (equal  lsp-ui-doc--bounds bounds)
286+   (if  lsp-ui-doc-mode
287+       (when  (and  (bound-and-true-p  lsp--cur-workspace)
288+                  (not  (bound-and-true-p  lsp-ui-peek-mode))
289+                  (lsp--capability " hoverProvider" 
290+         (cond 
291+          ((symbol-at-point )
292+           (let  ((bounds (bounds-of-thing-at-point  'symbol )))
293+             (unless  (equal  lsp-ui-doc--bounds bounds)
294+               (lsp--send-request-async (lsp--make-request " textDocument/hover" 
295+                                                           (lsp--text-document-position-params))
296+                                        (lambda  (hover )
297+                                          (lsp-ui-doc--callback hover bounds))))))
298+          ((looking-at  " [[:graph:]]" 
303299          (lsp--send-request-async (lsp--make-request " textDocument/hover" 
304300                                                      (lsp--text-document-position-params))
305301                                   (lambda  (hover )
306-                                      (lsp-ui-doc--callback hover bounds))))))
307-      ((looking-at  " [[:graph:]]" 
308-       (lsp--send-request-async (lsp--make-request " textDocument/hover" 
309-                                                   (lsp--text-document-position-params))
310-                                (lambda  (hover )
311-                                  (lsp-ui-doc--callback hover (cons  (point ) (1+  (point )))))))
312-      (t 
313-       (setq  lsp-ui-doc--string-eldoc nil )
314-       (lsp-ui-doc--hide-frame)))))
302+                                      (lsp-ui-doc--callback hover (cons  (point ) (1+  (point )))))))
303+          (t 
304+           (eldoc-message  nil )
305+           (lsp-ui-doc--hide-frame))))
306+     (funcall  orig-fn))
307+   nil )
315308
316309(defun  lsp-ui-doc--callback  (hover  bounds )
317310  " Process the received documentation.
@@ -323,7 +316,7 @@ BUFFER is the buffer where the request has been made."
323316      (let  ((doc (lsp-ui-doc--extract (gethash  " contents" 
324317        (setq  lsp-ui-doc--bounds bounds)
325318        (lsp-ui-doc--display (thing-at-point  'symbol  t ) doc))
326-     (setq  lsp-ui-doc--string- eldoc nil )
319+     (eldoc-message   nil )
327320    (lsp-ui-doc--hide-frame)))
328321
329322(defun  lsp-ui-doc--hide-frame  ()
@@ -643,14 +636,11 @@ HEIGHT is the documentation number of lines."
643636          ; ; ‘frameset-filter-alist’ for explanation.
644637          (cl-callf  copy-tree  frameset-filter-alist)
645638          (push  '(lsp-ui-doc-frame .  :never ) frameset-filter-alist)))
646-       ( add-hook   'lsp-after-open-hook   'lsp-ui-doc-enable-eldoc   nil   t ) 
647-       (add-hook   'post-command-hook   'lsp-ui-doc--make-request    nil   t )
639+ 
640+       (advice-add   'lsp-hover   :around   # 'lsp-ui-doc--hover  
648641      (add-hook  'delete-frame-functions  'lsp-ui-doc--on-delete  nil  t )))
649642   (t 
650-     (remove-hook  'delete-frame-functions  'lsp-ui-doc--on-delete  t )
651-     (remove-hook  'post-command-hook  'lsp-ui-doc--make-request  t )
652-     (remove-hook  'lsp-after-open-hook  'lsp-ui-doc-enable-eldoc  t )
653-     (setq-local  eldoc-documentation-function 'lsp--on-hover ))))
643+     (remove-hook  'delete-frame-functions  'lsp-ui-doc--on-delete  t ))))
654644
655645(defun  lsp-ui-doc-enable  (enable )
656646  " Enable/disable ‘lsp-ui-doc-mode’.
0 commit comments