+TITLE: ElDoc box
This package displays ElDoc documentations in a childframe. The childframe is selectable and scrollable with mouse, even though the cursor is hidden.
[[https://melpa.org/#/eldoc-box][file:https://melpa.org/packages/eldoc-box-badge.svg]]
[[https://stable.melpa.org/#/eldoc-box][file:https://stable.melpa.org/packages/eldoc-box-badge.svg]]
+CAPTION: Using with eglot in python-mode
[[./screenshot.png]]
- Install
Get the file, add to load path, and
+BEGIN_SRC emacs-lisp
(require 'eldoc-box)
+END_SRC
It is also available on [[https://melpa.org/#/eldoc-box][MELPA]].
- Usage
Note: If you use Gnome and Emacs 27, set ~x-gtk-resize-child-frames~ to ~resize-mode~ to avoid breakage of childframe.
** Function
- =eldoc-box-hover-mode= :: Enables a minor mode that displays documentation of the symbol at point in a childframe on upper corner.
- =eldoc-box-hover-at-point-mode= :: Same as =eldoc-box-hover-mode= except the childframe is displayed at point, instead of on the upper corner. /Note that this mode brings a small but noticeable slow-down./
- =eldoc-box-help-at-point= :: Display the documentation of the symbol at point in a temporary childframe, moving point or typing =C-g= disposes the childframe. This command simply displays what would be displayed by =eldoc-doc-buffer= in a childframe, so it requires Emacs 28, and =eldoc-box-hover-mode= doesn’t need to be on for this command to work.
- =eldoc-box-scroll-up/down= :: scrolls the childframe up/down.
** Face
- =eldoc-box-border= :: Adjust =:background= of this face for border color.
- =eldoc-box-body= :: Default face used by childframe. I suggest to use a nice sans serif font.
- =eldoc-box-markdown-separator=: Face for the separator line (=
=) in Markdown documentation.
** Hooks
- =eldoc-box-buffer-hook= :: A hook that runs after buffer for doc is setup. Run inside the new buffer every time before the new documentation is displayed.
- =eldoc-box-frame-hook= :: A hook that runs after doc frame is setup but just before it is made visible. Each function runs inside the child frame and receives the main frame as the sole argument.
** Variable
- =eldoc-box-max-pixel-width= & =eldoc-box-max-pixel-height= :: The max width/height of the childframe.
- =eldoc-box-only-multi-line= :: Set this to non-nil and eldoc-box will only display multi-line message in childframe, and one line messages are left in minibuffer.
- =eldoc-box-cleanup-interval= :: After this amount of seconds, eldoc-box will attempt to cleanup the childframe. E.g. if it is set to 1, the childframe is cleared 1 second after you moved the point to somewhere else (that doesn't have a doc to show). This doesn't apply to =eldoc-box-hover-at-point-mode=. In that mode, the childframe is cleared as soon as point moves.
- =eldoc-box-fringe-use-same-bg= :: Whether to set fringe’s background color to as same as that of default. Default to t.
- =eldoc-box-self-insert-command-list= :: By default =eldoc-box-hover-at-point-mode= only keeps childframe display while you are typing (ie, when =this-command= is =self-insert-command=). But if you bind something else to your keys, eldoc-box can’t recognize it and will hide childframe when you type. Add your command to this list so eldoc-box won’t hide childframe when this command is called.
- =eldoc-box-lighter= :: Lighter displayed on the mode line.
- =eldoc-box-buffer-setup-function= :: A function that runs in eldoc-box doc buffer for setup. See docstring for more information.
** Use with eglot
+BEGIN_SRC emacs-lisp
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t)
+END_SRC
To keep eldoc from displaying documentation at point without enabling any minor mode above: =(add-to-list 'eglot-ignored-server-capabilites :hoverProvider)=.
** Default prettifier
By default, eldoc-box tries to prettify the displayed markdown documentation as shown below. If you wish to disable them, remove the prettifier functions from =eldoc-box-buffer-hook=. Report an issue if there are other things can be prettfied away.
[[./demo.png]]
- Credit
- Thanks to [[https://github.com/joaotavora][João Távora]] for valuable contribution and explaining eldoc and eglot internals to me.
- This package is initially adapted from Sebastien Chapuis’s package lsp-ui.el.