2020-03-29 18:48:23 -04:00
|
|
|
;;; lang/org/contrib/roam.el -*- lexical-binding: t; -*-
|
|
|
|
;;;###if (featurep! +roam)
|
|
|
|
|
2020-04-24 16:03:46 -04:00
|
|
|
(defvar +org-roam-open-buffer-on-find-file t
|
|
|
|
"If non-nil, open the org-roam buffer when opening an org roam file.")
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;;; Packages
|
|
|
|
|
2020-03-29 18:48:23 -04:00
|
|
|
(use-package! org-roam
|
2020-04-08 21:24:49 +01:00
|
|
|
:hook (org-load . org-roam-mode)
|
2020-04-13 19:30:31 +02:00
|
|
|
:hook (org-roam-backlinks-mode . turn-on-visual-line-mode)
|
2020-04-16 15:16:06 -04:00
|
|
|
:commands (org-roam-buffer-toggle-display
|
2020-11-11 19:48:57 +04:00
|
|
|
org-roam-dailies-find-date
|
|
|
|
org-roam-dailies-find-today
|
|
|
|
org-roam-dailies-find-tomorrow
|
|
|
|
org-roam-dailies-find-yesterday)
|
2020-04-01 14:51:12 -04:00
|
|
|
:preface
|
2020-11-11 18:35:54 +01:00
|
|
|
;; Set this to nil so we can later detect if the user has set custom values
|
|
|
|
;; for these variables. If not, default values will be set in the :config
|
|
|
|
;; section.
|
2020-04-01 14:51:12 -04:00
|
|
|
(defvar org-roam-directory nil)
|
2020-11-11 18:35:54 +01:00
|
|
|
(defvar org-roam-db-location nil)
|
2020-03-29 18:48:23 -04:00
|
|
|
:init
|
|
|
|
(map! :after org
|
|
|
|
:map org-mode-map
|
|
|
|
:localleader
|
|
|
|
:prefix ("m" . "org-roam")
|
|
|
|
"b" #'org-roam-switch-to-buffer
|
|
|
|
"f" #'org-roam-find-file
|
2020-04-27 13:33:00 -04:00
|
|
|
"g" #'org-roam-graph
|
2020-04-01 17:26:37 -04:00
|
|
|
"i" #'org-roam-insert
|
2020-06-21 18:47:11 +05:30
|
|
|
"I" #'org-roam-insert-immediate
|
2020-04-01 17:26:37 -04:00
|
|
|
"m" #'org-roam
|
|
|
|
(:prefix ("d" . "by date")
|
2020-11-11 19:48:57 +04:00
|
|
|
:desc "Find previous note" "b" #'org-roam-dailies-find-previous-note
|
|
|
|
:desc "Find date" "d" #'org-roam-dailies-find-date
|
|
|
|
:desc "Find next note" "f" #'org-roam-dailies-find-next-note
|
|
|
|
:desc "Find tomorrow" "m" #'org-roam-dailies-find-tomorrow
|
|
|
|
:desc "Capture today" "n" #'org-roam-dailies-capture-today
|
|
|
|
:desc "Find today" "t" #'org-roam-dailies-find-today
|
|
|
|
:desc "Capture Date" "v" #'org-roam-dailies-capture-date
|
|
|
|
:desc "Find yesterday" "y" #'org-roam-dailies-find-yesterday
|
|
|
|
:desc "Find directory" "." #'org-roam-dailies-find-directory))
|
2020-03-29 18:48:23 -04:00
|
|
|
:config
|
2020-07-31 01:39:24 -04:00
|
|
|
(setq org-roam-directory
|
|
|
|
(file-name-as-directory
|
2020-10-11 16:33:25 -04:00
|
|
|
(file-truename
|
|
|
|
(expand-file-name (or org-roam-directory "roam")
|
|
|
|
org-directory)))
|
2020-11-11 18:35:54 +01:00
|
|
|
org-roam-db-location (or org-roam-db-location
|
|
|
|
(concat doom-etc-dir "org-roam.db"))
|
2020-07-31 01:39:24 -04:00
|
|
|
org-roam-verbose nil ; https://youtu.be/fn4jIlFwuLU
|
|
|
|
;; Make org-roam buffer sticky; i.e. don't replace it when opening a
|
|
|
|
;; file with an *-other-window command.
|
|
|
|
org-roam-buffer-window-parameters '((no-delete-other-windows . t))
|
2020-10-11 16:33:25 -04:00
|
|
|
org-roam-completion-everywhere t
|
2020-04-23 14:46:13 -04:00
|
|
|
org-roam-completion-system
|
|
|
|
(cond ((featurep! :completion helm) 'helm)
|
|
|
|
((featurep! :completion ivy) 'ivy)
|
|
|
|
((featurep! :completion ido) 'ido)
|
2020-05-02 12:39:14 -04:00
|
|
|
('default)))
|
2020-04-25 16:07:20 -04:00
|
|
|
|
2020-04-24 16:03:46 -04:00
|
|
|
;; Normally, the org-roam buffer doesn't open until you explicitly call
|
|
|
|
;; `org-roam'. If `+org-roam-open-buffer-on-find-file' is non-nil, the
|
|
|
|
;; org-roam buffer will be opened for you when you use `org-roam-find-file'
|
|
|
|
;; (but not `find-file', to limit the scope of this behavior).
|
|
|
|
(add-hook! 'find-file-hook
|
|
|
|
(defun +org-roam-open-buffer-maybe-h ()
|
|
|
|
(and +org-roam-open-buffer-on-find-file
|
|
|
|
(memq 'org-roam-buffer--update-maybe post-command-hook)
|
2020-04-25 15:52:38 -04:00
|
|
|
(not (window-parameter nil 'window-side)) ; don't proc for popups
|
2020-04-24 16:03:46 -04:00
|
|
|
(not (eq 'visible (org-roam-buffer--visibility)))
|
|
|
|
(with-current-buffer (window-buffer)
|
|
|
|
(org-roam-buffer--get-create)))))
|
|
|
|
|
2020-04-24 15:56:39 -04:00
|
|
|
;; Hide the mode line in the org-roam buffer, since it serves no purpose. This
|
2020-10-11 16:33:25 -04:00
|
|
|
;; makes it easier to distinguish from other org buffers.
|
|
|
|
(add-hook 'org-roam-buffer-prepare-hook #'hide-mode-line-mode))
|
2020-03-29 18:48:23 -04:00
|
|
|
|
|
|
|
|
|
|
|
;; Since the org module lazy loads org-protocol (waits until an org URL is
|
|
|
|
;; detected), we can safely chain `org-roam-protocol' to it.
|
|
|
|
(use-package! org-roam-protocol
|
|
|
|
:after org-protocol)
|