Treemacs doesn't follow a currently open file when shown for the first time

What happened?

Whenever sidebar is open with +treemacs-toggle (SPS o p) it’s always focusing on the root of the project, rather than the currently open file.

What did you expect to happen?

Treemacs is focused on the current file

Steps to reproduce

  1. SPC o p

System information


Loading data dump...

Also, I confirmed with treemacs developer that it’s not an issue in the upstream treemacs-project-follow-mode and treemacs-follow-mode focusing to the project root rather than an open file when sidebar shown · Issue #1035 · Alexander-Miller/treemacs · GitHub

Do you want treemacs-find-file? SPC o P will open treemacs at your current file.

No, that’s not what I want. I want treemacs to automatically focus to the currently open file.

M-x treemacs-follow-mode works for me. Maybe try doom upgrade/doom install?

Sure, it works if you have treemacs open, and then change buffers. However, just try this exact steps:

  1. open a fresh instance of emacs.
  2. switch projects
  3. open some file (ideally in some subdirectory)
  4. now open a treemacs with SPC o p

now, look at the position of cursor inside treemacs window. It’s at the root of the project, and not at your previously open buffer. At least that how it works for me in the most recent version of doom.

Okay but you’re not trying what I suggested. Enable treemacs-follow-mode and use SPC o P instead of SPC o p.

Here is a demonstration.

Oh I had brain fart. I didn’t notice the difference between p and P :man_facepalming:

Thanks! That work exactly like I want!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.