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

30 lines
1010 B
EmacsLisp

;; -*- lexical-binding: t; -*-
(use-package navi
:straight `(:local-repo ,(expand-file-name "~/.emacs.d/packages/navi"))
:defer t
:init
(defvar-keymap embark-navi-map
:doc "Keymap for actions on Navi cheats"
"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)