dotfiles/emacs/.emacs.d/config/init-navi.el

39 lines
1.3 KiB
EmacsLisp
Raw Normal View History

2024-05-03 19:29:31 +00:00
;; -*- lexical-binding: t; -*-
(use-package navi
:straight `(:local-repo ,(expand-file-name "packages/navi" user-emacs-directory) :type nil)
2024-05-03 19:29:31 +00:00
:defer t
:commands (navi
navi-by-tags
navi-matching-current-directory
navi-visit-cheat-file
navi-all-cheats
navi-cheats-for-tags
navi-cheats-matching-filename
navi-cheat-summary)
2024-05-03 19:29:31 +00:00
:init
(defvar-keymap embark-navi-map
:doc "Keymap for actions on Navi cheats"
:parent embark-general-map
2024-05-03 19:29:31 +00:00
"f" #'navi-visit-cheat-file)
(with-eval-after-load 'embark
(add-to-list 'embark-keymap-alist '(navi . embark-navi-map)))
(defun run-command-recipe-navi ()
(let* ((dir (or (projectile-project-root) default-directory))
(cheat-files
(append
(navi-cheats-matching-filename (regexp-quote dir)))))
(-mapcat
(lambda (cheat-file)
(-map (lambda (cheat)
(list :command-name (navi-cheat-summary cheat)
:command-line (lambda () (navi-cheat-render cheat))
:working-dir dir))
(oref cheat-file cheats)))
cheat-files)))
(with-eval-after-load 'run-command
(add-to-list 'run-command-recipes 'run-command-recipe-navi)))
(provide 'init-navi)