From aa126f50d98cc46a73d584639e23a6a31f2856ee Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Wed, 26 Apr 2023 14:06:44 +0200 Subject: Improve counsel-dash handling --- tw/home/files/emacs-init.el | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'tw/home/files/emacs-init.el') diff --git a/tw/home/files/emacs-init.el b/tw/home/files/emacs-init.el index 0662b914..9091cd6a 100644 --- a/tw/home/files/emacs-init.el +++ b/tw/home/files/emacs-init.el @@ -138,17 +138,33 @@ (defun tw/counsel-dash-is-help () "Install `counsel-dash-at-point' as `evil-lookup-func'." - (setq-local evil-lookup-func #'counsel-dash-at-point)) + ;; Note: `evil-lookup-func' is already set to something else by + ;; `tw/help-is-eldoc' for `eglot-mode'. + (setq-local evil-lookup-func #'counsel-dash-at-point + counsel-dash-docsets + (cl-case major-mode + (python-mode '("Python 3")) + (c++-mode '("C++")) + (cmake-mode '("CMake")) + (puppet-mode '("Puppet")) + (tcl-mode '("Tcl")) + (common-lisp-mode '("Common Lisp"))))) (use-package counsel-dash - :after (dash-docs) + :after (dash-docs which-key) :commands (counsel-dash-at-point) :demand t - :bind (("K" . counsel-dash-at-point) ; TODO: just install as `evil-lookup-func'? + :init (which-key-add-key-based-replacements + "d" '("docs" . "Documentation")) + :bind (("K" . counsel-dash-at-point) ("dK" . counsel-dash) ("di" . counsel-dash-install-docset) ("da" . counsel-dash-activate-docset) ("dd" . counsel-dash-deactivate-docset)) - :hook (python-mode . tw/counsel-dash-is-help) + :hook ((python-mode cmake-mode c++-mode puppet-mode tcl-mode common-lisp-mode) + . tw/counsel-dash-is-help) + :config + ;; Activate all installed docsets by default. + (setq counsel-dash-common-docsets (dash-docs-installed-docsets)) :custom (counsel-dash-docsets-path (tw/xdg-emacs-subdir 'data "dash-docsets/") "Store docsets in the XDG data directory.") (counsel-dash-browser-func 'eww "Open documentation pages using `eww' instead of an external browser.") -- cgit v1.2.3