   (setq beancount-electric-currency t)
 
   (map! :map beancount-mode-map
+        "TAB" (cmds! (and outline-minor-mode (outline-on-heading-p))
+                     #'beancount-outline-cycle
+                     #'indent-according-to-mode)
         :localleader
         "b" #'+beancount/balance
         "c" #'beancount-check

;;; lang/beancount/config.el -*- lexical-binding: t; -*-

(use-package! beancount-mode
  :mode "\\.beancount\\'"
  :init
  (add-hook 'beancount-mode-hook #'outline-minor-mode)

                 '("\\.beancount\\'" all-the-icons-material "attach_money" :face all-the-icons-lblue))
    (add-to-list 'all-the-icons-mode-icon-alist
                 '(beancount-mode all-the-icons-material "attach_money" :face all-the-icons-lblue)))

  ;; TODO PR this upstream
  (defadvice! +beancount--fix-faces-a ()
    "`beancount-outline-face' returns org-level-N faces for beancount-mode's
font-lock keywords, but there is no guarantee `org' will be loaded when
beancount-mode is activated. If it is absent, you will see a flood of 'invalid
face' errors. Just use the outline-N faces to get around this.

This msut be advised *before* beancount-mode loads, because
`beancount-outline-face' is used at load time."
    :override #'beancount-outline-face
    (if outline-minor-mode
        (let ((level (funcall outline-level)))
          (if (integerp level)
              (intern (format "outline-%d" level))))
      nil))

  :config
  (when (featurep! +lsp)
    (add-hook 'beancount-mode-local-vars-hook #'lsp!))
