Files
doomemacs/modules/lang/beancount/config.el
Henrik Lissner 440e952056 fix(beancount): +beancount/balance: make v3 compliant
bean-report was removed in beancount v3+, so we defer to bean-query,
which is present in both v2 and v3 (though it lives in a separate repo
in v3).
2025-04-30 03:54:15 -04:00

46 lines
1.8 KiB
EmacsLisp

;;; lang/beancount/config.el -*- lexical-binding: t; -*-
(use-package! beancount
:hook (beancount-mode . outline-minor-mode)
:hook (beancount-mode . flymake-bean-check-enable) ; FIXME: add proper flycheck support
:init
(after! nerd-icons
(add-to-list 'nerd-icons-extension-icon-alist
'("beancount" nerd-icons-faicon "nf-fa-money" :face nerd-icons-lblue))
(add-to-list 'nerd-icons-mode-icon-alist
'(beancount-mode nerd-icons-faicon "nf-fa-money" :face nerd-icons-lblue)))
:config
(setq beancount-electric-currency t)
(when (modulep! +lsp)
(add-hook 'beancount-mode-local-vars-hook #'lsp! 'append))
;; HACK: The intro message changed in newer versions of Fava, plus, the output
;; could contain ANSI codes, causing the `beancount-fava' command to not
;; open the server in the browser after the server has started.
;; REVIEW: PR this upstream!
(defadvice! +beancount--open-in-browser-after-starting-fix-a (_process output)
:override #'beancount--fava-filter
(save-match-data
(let ((output (ansi-color-filter-apply output)))
(when-let ((url (string-match "\\(?:Starting\\|Running\\) Fava on \\(http://.+:[0-9]+\\)\n" output)))
(browse-url (match-string 1 output))))))
(map! :map beancount-mode-map
:m "[[" #'+beancount/previous-transaction
:m "]]" #'+beancount/next-transaction
:localleader
"b" #'+beancount/balance
"c" #'beancount-check
"s" #'+beancount/occur
"l" #'beancount-linked
"q" #'beancount-query
"x" #'beancount-context
(:prefix ("i" . "insert")
"c" #'+beancount/clone-transaction
"C" #'+beancount/clone-this-transaction
"a" #'beancount-insert-account
"p" #'beancount-insert-prices
"d" #'beancount-insert-date)))