The Org-roam v2 Great Migration

I think that it would be great to have some standard configuration file for people using doom emacs.

My configuration at the moment is attached. I hope this might help other people migrating.

EDIT: I finally got the org-roam-buffer to be configured correctly on doom emacs. changed the config below accordingly.

(setq org-roam-v2-ack t)

(use-package! org-roam
  :init
  (setq org-roam-v2-ack t)
  (map! :leader
        (:prefix-map ("n" . "notes")
         (:prefix ("r" . "roam")
          :desc "Insert new roam node" "i" #'org-roam-node-insert
          :desc "Find roam node" "f" #'org-roam-node-find
          :desc "Roam buffer" "r" #'org-roam-buffer-toggle
          (:prefix ("d" . "dailies")
           :desc "today" "d" (lambda () (interactive) (org-roam-dailies-capture-today t))
           :desc "today" "y" (lambda () (interactive) (org-roam-dailies-capture-yesterday t))
           :desc "tomorrow" "t" (lambda () (interactive) (org-roam-dailies-capture-tomorrow t))))))

  (setq org-roam-completion-everywhere 'nil)
  (setq org-roam-directory (file-truename "~/Dropbox/org-roam"))
  (setq org-roam-db-location "~/org-roam.db")

  :config
  (org-roam-setup)

  (add-hook 'org-roam-mode-hook #'turn-on-visual-line-mode)

  (setq org-roam-mode-section-functions
        (list #'org-roam-backlinks-section
              #'org-roam-reflinks-section
              #'org-roam-unlinked-references-section
              ))


  (setq org-roam-capture-templates
        '(("d" "default" plain "%?" :target
           (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
                      "#+TITLE: ${title}\n#+CREATED: %U\n#+LAST_MODIFIED: %U\n#+OPTIONS: toc:nil, ':t\n#+SETUPFILE: ~/.doom.d/templates/org_latex_header.org\n\n\n\n* References \nbibliographystyle:unsrt\nbibliography:~/references.bib\n")
           :unnarrowed t)
          ("b" "book review" plain "%?" :target
           (file+head "books/%<%Y%m%d%H%M%S>-book-${slug}"
                      "#+TITLE: ${title}\n#+CREATED: %U\n#+LAST_MODIFIED: %U\n#+OPTIONS: toc:nil, ':t\n#+SETUPFILE: ~/.doom.d/templates/org_latex_header.org\n\n* Source\n\n- Author: %^{Author}\n- Title: ${title}\n\n* What I thought\n\n%?\n\n* References \nbibliographystyle:unsrt\nbibliography:~/references.bib\n")
           :unnarrowed t)
          ("p" "personal note" plain "%?" :target
           (file+head "personal/%<%Y%m%d%H%M%S>-personal-${slug}"
                      "#+TITLE: ${title}\n#+CREATED: %U\n#+LAST_MODIFIED: %U\n#+OPTIONS: toc:nil, ':t\n#+SETUPFILE: ~/.doom.d/templates/org_latex_header.org\n#+ROAM_TAGS: personal\n\n\n\n* References \nbibliographystyle:unsrt\nbibliography:~/references.bib\n")
           :unnarrowed t)))


  (setq org-roam-dailies-capture-templates
        '(("d" "default" entry "* %?" :target
           (file+head "%<%Y-%m-%d>.org"
                      "#+title: %<%Y-%m-%d>\n#+CREATED: %U\n#+LAST_MODIFIED: %U\n#+OPTIONS: toc:nil, ':t\n#+SETUPFILE: ~/.doom.d/templates/org_latex_header.org\n\n")
           :add-created t
           :jump-to-captured t
           :unnarrowed t)))


  (setq org-roam-node-display-template
        (concat "${title:80} " (propertize "${tags:20}" 'face 'org-tag))
        org-roam-node-annotation-function
        (lambda (node) (marginalia--time (org-roam-node-file-mtime node))))


  ;; mouse use for the org-roam buffer
  ;; https://org-roam.discourse.group/t/backlinks-in-org-roam-buffer/1947/20?u=nobiot
  (define-key org-roam-node-map [mouse-1] #'org-roam-node-visit)
  (define-key org-roam-preview-map [mouse-1] #'org-roam-preview-visit)


  ;;
  ;; Showing the number of backlinks for each node in org-roam-node-find
  ;;
  (cl-defmethod org-roam-node-directories ((node org-roam-node))
    (if-let ((dirs (file-name-directory (file-relative-name (org-roam-node-file node) org-roam-directory))))
        (format "(%s)" (car (f-split dirs)))
      ""))

  (cl-defmethod org-roam-node-backlinkscount ((node org-roam-node))
    (let* ((count (caar (org-roam-db-query
                         [:select (funcall count source)
                          :from links
                          :where (= dest $s1)
                          :and (= type "id")]
                         (org-roam-node-id node)))))
      (format "[%d]" count)))

  (setq org-roam-node-display-template "${directories:10} ${tags:10} ${title:100} ${backlinkscount:6}")


  ;; mathjax
  ;;
  (setq org-html-mathjax-template
        (let ((mathjax-template (expand-file-name "templates/mathjax_org_template.html" doom-private-dir)))
          (with-temp-buffer
            (insert-file-contents mathjax-template)
            (buffer-string))))

  )

(after! popup
  (set-popup-rule! "\\*org-roam\\*"
    :side 'right
    :width 0.33
    :slot 0
    :parameters '((no-other-window . t)
                 (no-delete-other-windows . t))))



2 Likes