eldoc 显示在 minibuffer 里,输入代码的时候时有时无,非常难受,就把显示搬到 headline 上了。
https://git.sr.ht/~meow_king/eldoc-headline/tree/main/item/eldoc-headline.el
(defgroup eldoc-headline nil
"Tree Sitter enabled Typst Writing."
:group 'eldoc)
(defcustom eldoc-headline-disable-echo-area nil
"Whether to disable `eldoc-display-in-echo-area' or not."
:type 'boolean
:group 'eldoc-headline)
(defvar eldoc-headline--string "")
(defun eldoc-headline-display (docs _interactive)
(let ((width (1- (window-width (minibuffer-window))))
(string
(with-temp-buffer
(eldoc--echo-area-render docs)
(buffer-substring (goto-char (point-min))
(progn (end-of-visible-line)
(point))))))
(setq eldoc-headline--string
(if (> (length string) width) ; truncation to happen
(truncate-string-to-width string width)
string))))
(defun eldoc-headline--setup()
(add-to-list 'header-line-format '(:eval eldoc-headline--string))
(if eldoc-headline-disable-echo-area
(remove-hook 'eldoc-display-functions #'eldoc-display-in-echo-area))
(add-hook 'eldoc-display-functions #'eldoc-headline-display))
(defun eldoc-headline--cleanup()
(setq header-line-format (delete '(:eval eldoc-headline--string) header-line-format))
(if eldoc-headline-disable-echo-area
(add-hook 'eldoc-display-functions #'eldoc-display-in-echo-area))
(remove-hook 'eldoc-display-functions #'eldoc-headline-display))
;;;###autoload
(define-minor-mode eldoc-headline-local-mode
"Toogle buffer local eldoc headline mode."
:init-value nil
:group 'eldoc-headline
:lighter "eldoc-headline"
(if eldoc-headline-local-mode (eldoc-headline--setup)
(eldoc-headline--cleanup)))
(define-globalized-minor-mode eldoc-headline-mode eldoc-headline-local-mode
(lambda () (eldoc-headline-local-mode 1)))
效果: