diff --git a/Cask b/Cask index 02f850ce3..d1ef747e2 100644 --- a/Cask +++ b/Cask @@ -64,6 +64,7 @@ (depends-on "avy") (depends-on "dumb-jump") (depends-on "editorconfig") +(depends-on "eldoc-eval") (depends-on "emr") (depends-on "expand-region") (depends-on "fancy-narrow") diff --git a/core/core-ui.el b/core/core-ui.el index d69b179a1..bbc478299 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -76,6 +76,11 @@ (when (and (> emacs-major-version 24) (featurep 'eldoc)) (global-eldoc-mode -1)) +(use-package eldoc-eval + :config + (setq eldoc-in-minibuffer-show-fn 'doom/eldoc-show-in-mode-line) + (eldoc-in-minibuffer-mode +1)) + ;; Highlight TODO/FIXME/NOTE tags (add-hook! (prog-mode emacs-lisp-mode css-mode) (font-lock-add-keywords @@ -417,6 +422,21 @@ anzu to be enabled." (global :when active) *buffer-position)) + ;; + (spaceline-define-segment *eldoc + (and (bound-and-true-p str) str) + :tight t + :face 'mode-line) + + (spaceline-define-segment *eldoc-pad + "Padding, to ensure the mode-line is `powerline-height' pixels tall" + (pl/percent-xpm powerline-height 100 0 100 0 3 "#B3EF00" nil) + :tight t + :face 'mode-line) + + (spaceline-compile + 'eldoc '(*eldoc-pad *eldoc) '()) + ;; Initialize modeline (setq-default mode-line-format '("%e" (:eval (spaceline-ml-main))))) diff --git a/core/defuns/defuns-ui.el b/core/defuns/defuns-ui.el index 11baafef9..8471c1c59 100644 --- a/core/defuns/defuns-ui.el +++ b/core/defuns/defuns-ui.el @@ -65,5 +65,32 @@ (defun doom|hide-mode-line (&rest _) (setq mode-line-format nil)) +;;;###autoload +(defun doom/eldoc-show-in-mode-line (input) + "Display string STR in the mode-line next to minibuffer." + (with-current-buffer (eldoc-current-buffer) + (let* ((max (window-width (selected-window))) + (str (and (stringp input) (concat " " input))) + (len (length str)) + (tmp-str str) + (mode-line-format (or (and str `(:eval (spaceline-ml-eldoc))) + mode-line-format)) + roll mode-line-in-non-selected-windows) + (catch 'break + (if (and (> len max) eldoc-mode-line-rolling-flag) + (progn + (while (setq roll (sit-for 0.3)) + (setq tmp-str (substring tmp-str 2) + mode-line-format (concat tmp-str " [<]" str)) + (force-mode-line-update) + (when (< (length tmp-str) 2) (setq tmp-str str))) + (unless roll + (when eldoc-mode-line-stop-rolling-on-input + (setq eldoc-mode-line-rolling-flag nil)) + (throw 'break nil))) + (force-mode-line-update) + (sit-for eldoc-show-in-mode-line-delay)))) + (force-mode-line-update))) + (provide 'defuns-ui) ;;; defuns-ui.el ends here