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-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
|
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-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-07-20 13:47:07 +02:00
|
|
|
(setq org-roam-directory (file-name-as-directory (expand-file-name (or org-roam-directory "roam")
|
|
|
|
org-directory))
|
2020-04-10 23:34:57 -04:00
|
|
|
org-roam-verbose nil ; https://youtu.be/fn4jIlFwuLU
|
2020-06-05 15:58:45 +08:00
|
|
|
org-roam-buffer-window-parameters '((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)
|
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
|
|
|
|
;; makes it easier to distinguish among other org buffers.
|
2020-07-29 14:28:27 -04:00
|
|
|
(add-hook 'org-roam-buffer-prepare-hook #'hide-mode-line-mode)
|
|
|
|
|
|
|
|
;; REVIEW Fixes an unhelpful "wrong-type-argument: stringp" error which occurs
|
|
|
|
;; if sqlite3 isn't installed. Remove this once addressed upstream.
|
|
|
|
(defadvice! +org-fail-gracefully-when-sqlite-is-absent-a (orig-fn &rest args)
|
|
|
|
:around #'org-roam-mode
|
|
|
|
(let ((emacsql-sqlite3-executable
|
|
|
|
(or (bound-and-true-p emacsql-sqlite3-executable)
|
|
|
|
"sqlite3")))
|
|
|
|
(apply orig-fn args))))
|
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)))
|