]> git.eshelyaron.com Git - emacs.git/commitdiff
Remap display-local-help (c-h .) to eglot-help-at-point
authorJoão Távora <joaotavora@gmail.com>
Sun, 3 May 2020 20:10:05 +0000 (21:10 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sun, 3 May 2020 20:10:05 +0000 (21:10 +0100)
* eglot.el (eglot-help-at-point): Fallback to display-local-help if no
hover doc
(eglot-mode-map): Remap display-local-help to eglot-help-at-point..

GitHub-reference: per https://github.com/joaotavora/eglot/issues/437

lisp/progmodes/eglot.el

index 09be1f8dc611e9021400b37a9ae33f8599f8fb43..8fadd5f7ab360a1f1c3af48d74172db0e257940c 100644 (file)
@@ -1238,7 +1238,10 @@ and just return it.  PROMPT shouldn't end with a question mark."
 \f
 ;;; Minor modes
 ;;;
-(defvar eglot-mode-map (make-sparse-keymap))
+(defvar eglot-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [remap display-local-help] 'eglot-help-at-point)
+    map))
 
 (defvar-local eglot--current-flymake-report-fn nil
   "Current flymake report function for this buffer")
@@ -2247,19 +2250,20 @@ is not active."
       (setq eglot--help-buffer (generate-new-buffer "*eglot-help*"))))
 
 (defun eglot-help-at-point ()
-  "Request \"hover\" information for the thing at point."
+  "Request documentation for the thing at point."
   (interactive)
   (eglot--dbind ((Hover) contents range)
       (jsonrpc-request (eglot--current-server-or-lose) :textDocument/hover
                        (eglot--TextDocumentPositionParams))
-    (when (seq-empty-p contents) (eglot--error "No hover info here"))
-    (let ((blurb (eglot--hover-info contents range))
-          (sym (thing-at-point 'symbol)))
-      (with-current-buffer (eglot--help-buffer)
-        (with-help-window (current-buffer)
-          (rename-buffer (format "*eglot-help for %s*" sym))
-          (with-current-buffer standard-output (insert blurb))
-          (setq-local nobreak-char-display nil))))))
+    (if (seq-empty-p contents)
+        (display-local-help)
+      (let ((blurb (eglot--hover-info contents range))
+            (sym (thing-at-point 'symbol)))
+        (with-current-buffer (eglot--help-buffer)
+          (with-help-window (current-buffer)
+            (rename-buffer (format "*eglot-help for %s*" sym))
+            (with-current-buffer standard-output (insert blurb))
+            (setq-local nobreak-char-display nil)))))))
 
 (defun eglot-doc-too-large-for-echo-area (string)
   "Return non-nil if STRING won't fit in echo area.