Add option to leave message in minibuffer when there's only one line

This commit is contained in:
Yuan Fu 2018-12-11 11:16:02 -05:00
parent 445a56e2fb
commit 194ff4136a
No known key found for this signature in database
GPG Key ID: 1CF5ECABEC37A901
2 changed files with 12 additions and 6 deletions

View File

@ -7,11 +7,11 @@ Get the file, add to load path, and
#+END_SRC
* Usage
Show the documentation of the symbol at point: =eldoc-box-help-at-point=
Show documentation upon hover: =eldoc-box-hover-mode=. Note that you need to enable ElDoc mode for this to work.
Adjust =:background= of =eldoc-box-border= face for border color. Adjust =:background= of =eldoc-box-body= face for background color of childframe.
- =eldoc-box-help-at-point= :: Show the documentation of the symbol at point.
- =eldoc-box-hover-mode= :: Show documentation upon hover. Note that you need to enable ElDoc mode for this to work.
- =eldoc-box-border= :: Adjust =:background= of this face for border color.
- =eldoc-box-body= :: Adjust =:background= of this face for background color of childframe.
- =eldoc-box-only-multi-line= :: Set this to non-nil and eldoc-box only display multi-line message in childframe. One line messages are left in minibuffer.
** Use with eglot
As of writing this README, eglot doesn't have a public mode hook, use this hook:

View File

@ -39,6 +39,9 @@
(defface eldoc-box-body '((t . (:background nil)))
"Body face used in eglot doc childframe. Only :background is used.")
(defvar eldoc-box-only-multi-line nil
"If non-nil, only use childframe when there are more than one line.")
(defvar eldoc-box-frame-parameters
'(
;; (left . -1)
@ -169,7 +172,10 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'."
"Frontend for eldoc. Display STR in childframe and ARGS works like `message'."
(when str
(eldoc-box-quit-frame)
(eldoc-box--display (apply #'format str args))))
(let ((doc (apply #'format str args)))
(if (and eldoc-box-only-multi-line (eq (cl-count ?\n doc) 0))
(apply #'eldoc-minibuffer-message str args)
(eldoc-box--display (apply #'format str args))))))
(define-minor-mode eldoc-box-hover-mode
"Displays hover documentations in a childframe. This mode is buffer local."