syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

How can I make org-roam's buffer look useful and nice like it does in doom emacs? #16519

Open komali2 opened 1 month ago

komali2 commented 1 month ago

My org roam buffer is quite ugly in spacemacs, and basically useless, however it looks quite nice in doom emacs, when pointing to the same org-roam directory.

First, it was completely useless until I switched off global-page-break-lines-mode (see https://github.com/org-roam/org-roam/issues/1772). Now it's at least usable, however I'd like to configure it to look very nice and usable like it does in doom emacs.

Here's how it looks for me in spacemacs:

2024-08-06-220311_1899x701_scrot

And here's how it looks for the same file in doom emacs:

2024-08-06-215919_655x617_scrot

I'm less concerned with font faces and more really into the automated indenting in the doom version, as well as the fact that in doom, the org roam buffer automatically refreshes when I change. Also, in Doom the buffer just functions like an org file, and I can move around it quite easily, whereas in Spacemacs I constantly get errors if I press SPC for example to run an arbitrary command (Wrong type argument: commandp, spacemacs-cmds). I also like how in doom emacs, the lines actually wrap. I feel like I must have accidentally seriously misconfigured something when installing org roam.

Any ideas on how to make this prettier?

My spacemacs config: https://github.com/komali2/Configs/blob/master/emacs/.spacemacs

My Doom config: https://github.com/komali2/Configs/tree/master/emacs/.doom.d

Emacs: GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) of 2023-11-14 Spacemacs: Spacemacs v.0.999.0

Edit: See below for some changes I made that made a pretty big difference. The only thing remaining is changing how the org roam buffer displays subheaders and content, e.g., instead of showing

2022-04-26 (good explanation of react useEffect)
content

It shows

* 2022-04-26
    * good explanation of react useEffect
        content
komali2 commented 1 month ago

I've gotten a little bit closer by copying some of doom emacs' org roam settings: https://github.com/doomemacs/doomemacs/blob/master/modules/lang/org/contrib/roam2.el

2024-08-07-100332_1290x627_scrot

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

The face for the backlink filename is org-roam-olp

komali2 commented 1 month ago

Another step: make it so backlinks show a subset of content, preferably just the line or paragraph the backlink is in, rather than the entire file:

https://github.com/org-roam/org-roam/issues/1934

Add to configuration:

(defun my/preview-fetcher ()
  (let* ((elem (org-element-context))
         (parent (org-element-property :parent elem)))
    ;; TODO: alt handling for non-paragraph elements
    (string-trim-right (buffer-substring-no-properties
                        (org-element-property :begin parent)
                        (org-element-property :end parent)))))

(setq org-roam-preview-function #'my/preview-fetcher)

After reloading config or restarting emacs, I believe running org-roam-db-sync is required to see the change. However, there's some kind of bug in org right now that causes that function to fail for any org file with id links in them (so, ALL org roam related files), see https://github.com/syl20bnr/spacemacs/issues/16520 for the spacemacs specific fix and https://github.com/org-roam/org-roam/issues/2361 for the main issue.

Here's how it's looking now for me:

2024-08-07-111458_1283x942_scrot

smile13241324 commented 2 weeks ago

I would be willing to try to improve the visual appearance of org-roam buffers (though I would prefer org-roam-ui anyway) but I need an example file and example config for org-roam. Would you be willing to provide a minimal example file and config for me @komali2?

komali2 commented 2 weeks ago

Wait, what's org-roam-ui ? I would like to check it out.

Hmm, minimal will take me a second to set up, but here's my config:

https://github.com/komali2/Configs/blob/master/emacs/.spacemacs

nickanderson commented 2 weeks ago

Wait, what's org-roam-ui ? I would like to check it out. https://github.com/org-roam/org-roam-ui https://fosstodon.org/tags/OrgRoamUi