Skip to content

Commit

Permalink
Add option to leave message in minibuffer when there's only one line
Browse files Browse the repository at this point in the history
  • Loading branch information
casouri committed Dec 11, 2018
1 parent 445a56e commit 194ff41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion eldoc-box.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit 194ff41

Please sign in to comment.