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-04-08 21:24:49 +01:00
|
|
|
org-roam-find-file
|
2020-04-27 13:33:00 -04:00
|
|
|
org-roam-graph
|
2020-04-08 21:24:49 +01:00
|
|
|
org-roam-insert
|
|
|
|
org-roam-switch-to-buffer
|
2020-04-17 14:05:15 -04:00
|
|
|
org-roam-dailies-date
|
|
|
|
org-roam-dailies-today
|
|
|
|
org-roam-dailies-tomorrow
|
|
|
|
org-roam-dailies-yesterday)
|
2020-04-01 14:51:12 -04:00
|
|
|
:preface
|
|
|
|
;; Set this to nil so we can later detect whether the user has set a custom
|
|
|
|
;; directory for it, and default to `org-directory' if they haven't.
|
|
|
|
(defvar org-roam-directory 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
|
|
|
|
"m" #'org-roam
|
|
|
|
(:prefix ("d" . "by date")
|
2020-04-17 14:05:15 -04:00
|
|
|
:desc "Arbitrary date" "d" #'org-roam-dailies-date
|
|
|
|
:desc "Today" "t" #'org-roam-dailies-today
|
|
|
|
:desc "Tomorrow" "m" #'org-roam-dailies-tomorrow
|
|
|
|
:desc "Yesterday" "y" #'org-roam-dailies-yesterday))
|
2020-03-29 18:48:23 -04:00
|
|
|
:config
|
2020-04-25 15:40:24 -04:00
|
|
|
(setq org-roam-directory (expand-file-name (or org-roam-directory "roam")
|
2020-04-10 14:40:14 -04:00
|
|
|
org-directory)
|
2020-04-10 23:34:57 -04:00
|
|
|
org-roam-verbose nil ; https://youtu.be/fn4jIlFwuLU
|
2020-04-24 15:54:53 -04:00
|
|
|
org-roam-buffer-no-delete-other-windows t ; make org-roam buffer sticky
|
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)
|
|
|
|
('default))
|
|
|
|
org-roam-completion-fuzzy-match
|
|
|
|
(or (featurep! :completion helm +fuzzy)
|
|
|
|
(featurep! :completion ivy +fuzzy)))
|
2020-04-16 15:18:43 -04:00
|
|
|
|
2020-04-25 16:07:20 -04:00
|
|
|
;; HACK On first invocation, `org-roam-db-build-cache' builds the cache with a
|
|
|
|
;; list of unresolved file paths. If those are symlinks, you will later
|
|
|
|
;; end up with duplicate entries in your roam DB (e.g. after
|
|
|
|
;; `org-roam-capture'ing to an existing file).
|
2020-04-25 16:24:31 -04:00
|
|
|
;; REVIEW When jethrokuan/org-roam#518 is merged
|
2020-04-25 16:07:20 -04:00
|
|
|
(defadvice! +org-roam-resolve-symlinks-a (args)
|
|
|
|
:filter-args #'org-roam--list-files
|
|
|
|
(setcar args (file-truename (car args)))
|
|
|
|
args)
|
|
|
|
|
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
|
|
|
|
;; makes it easier to distinguish among 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)
|
|
|
|
|
|
|
|
|
2020-03-29 22:04:15 -04:00
|
|
|
(use-package! company-org-roam
|
2020-03-29 18:48:23 -04:00
|
|
|
:when (featurep! :completion company)
|
|
|
|
:after org-roam
|
|
|
|
:config
|
|
|
|
(set-company-backend! 'org-mode '(company-org-roam company-yasnippet company-dabbrev)))
|