feat(org): org-roam-insert spacing in normal mode

Fix: #8513
This commit is contained in:
Henrik Lissner
2025-09-19 00:47:57 -04:00
parent ba18967855
commit 849b1e4aa8

View File

@@ -47,6 +47,21 @@ In case of failure, fail gracefully."
(advice-remove 'org-roam-db-query #'+org-roam-try-init-db-a)
(org-roam-db-sync))
(defadvice! +org-roam-node-insert-after-point-a (fn &rest args)
"If in evil normal mode and cursor is on a whitespace character, insert the
link after the whitespace rather than before. If at EOL, add a space before
inserting the link."
:around #'org-roam-node-insert
(if (and (bound-and-true-p evil-local-mode)
(not (evil-insert-state-p))
(or (looking-at-p "[[:blank:]]")
(evil-eolp)))
(evil-with-state 'insert
(unless (eolp) (forward-char))
(if (evil-eolp) (insert " "))
(apply fn args))
(apply fn args)))
(setq org-roam-directory
(thread-first (or org-roam-directory "roam")
(expand-file-name org-directory)