Alexander-Miller / treemacs

GNU General Public License v3.0
2.12k stars 155 forks source link

Useless Workspaces are Created #1062

Closed Caliv0 closed 1 year ago

Caliv0 commented 1 year ago

I have a project with the folder name frontend. Whenever I open this project and then open treemacs my home directory ($HOME) opens instead of the project workspace.

After running treemacs-edit-workspaces I noticed that every time I open the project, three new entries are added.

* No Perspective
** caliv0
 - path :: ~
* Perspective frontend
** caliv0
 - path :: ~
* Perspective frontend
** caliv0
 - path :: ~

This issue persisted even after completely nuking my Emacs config and rebuilding it with doom install.

I've played around with treemacs-set-scope-type but nothing changed. This issue started to appear after I updated Doom Emacs with all its packages about a month ago.

I also set (setq treemacs-find-workspace-method 'find-for-file-or-manually-select) but I was never asked which workspace I wanted to use after opening a new project, only when editing and deleting the currently selected workspace with treemacs-edit-workspaces I'm asked.

Here is my complete treemacs config:

(after! treemacs
  ;;(setq treemacs-file-extension-regex treemacs-first-period-regex-value)
  (setq doom-themes-treemacs-theme "Default")
  (doom-themes-treemacs-config)
  (treemacs-git-mode 'extended)
  (treemacs-git-commit-diff-mode)
  (treemacs-indent-guide-mode)
  (treemacs-follow-mode)
  (treemacs-hide-gitignored-files-mode)
  (setq treemacs-find-workspace-method 'find-for-file-or-manually-select)
  (setq treemacs-recenter-after-file-follow t)
  (setq treemacs-recenter-after-tag-follow t)
  (setq treemacs-show-hidden-files nil)
  (setq treemacs-silent-refresh t)
  (setq treemacs-workspace-switch-cleanup "files")
  (treemacs-toggle-fixed-width)
  (treemacs-resize-icons 18)
  (treemacs-modify-theme "Default"
    :config
    (progn
      ;; Folders
      (treemacs-create-icon :file (concat doom-user-dir "icons/folder-open.svg") :extensions (dir-open "icons-open" "bin-open" "public-open" "private-open"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/folder.svg") :extensions (dir-closed "icons-closed" "bin-closed" "private-closed" "public-closed"))

      ;; Concat to add space https://github.com/Alexander-Miller/treemacs/issues/735
      (treemacs-create-icon :icon (concat (all-the-icons-material "folder_special" :height 1.5 :v-adjust 0.05 :face 'treemacs-root-face) " ") :extensions (root-open))
      (treemacs-create-icon :icon (concat (all-the-icons-material "folder_special" :height 1.5 :v-adjust 0.05 :face 'treemacs-root-face) " ") :extensions (root-closed))

      ;; Files
      (treemacs-create-icon :icon (concat (all-the-icons-alltheicon "terminal" :v-adjust 0.05) " ") :extensions ("bash" "bashrc" "bash_profile" "fish" "zshrc" "zsh" "sh"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/settings.svg") :extensions ("json"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/csharp.svg") :extensions ("cs"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/css.svg") :extensions ("scss" "css" "less" "sass"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/html.svg") :extensions ("html"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/dotnet.svg") :extensions ("sln" "csproj"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/angular.svg") :extensions ("angular.json"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/store-open.svg") :extensions ("store-open" "state-open"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/store-closed.svg") :extensions ("store-closed" "state-closed"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/actions-open.svg") :extensions ("actions-open"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/actions-closed.svg") :extensions ("actions-closed"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/actions.svg") :extensions ("actions.ts"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/selectors-open.svg") :extensions ("selectors-open"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/selectors-closed.svg") :extensions ("selectors-closed"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/selectors.svg") :extensions ("selectors.ts"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/reducer-open.svg") :extensions ("reducer-open" "state-open"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/reducer-closed.svg") :extensions ("reducer-closed" "state-closed"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/reducer.svg") :extensions ("state.ts" "reducer.ts"))
      (treemacs-create-icon :file (concat doom-user-dir "icons/typescript.svg") :extensions ("ts"))
      (treemacs-create-icon :icon (concat (all-the-icons-faicon "file-text" :v-adjust 0.05) " ") :extensions ("yasnippet" "env" "txt"))

      (treemacs-create-icon :file (concat doom-user-dir "icons/file.svg") :extensions (unknown))
      (treemacs-create-icon :file (concat doom-user-dir "icons/file.svg") :extensions (fallback))
      )
    ;; Reduce Space https://github.com/Alexander-Miller/treemacs/issues/735
    (let ((icons (treemacs-theme->gui-icons theme)))
      (maphash
       (lambda (ext icon)
         (puthash ext (concat (substring icon 0 1)
                              (propertize " " 'display '(space . (:width 0.2))))
                  icons))
       icons))
    )
  )

I have enabled workspaces for Doom Emacs, which means that the treemacs-scope-type is set to Perspectives.

How can I configure treemacs in a way that these workspaces are no longer created, and the correct workspace is being used?

There are the rest of my workspaces:

* Project Frontend
** Frontend
 - path :: ~/dev/project/frontend
* Perspective Project Backend
** Backend
 - path :: ~/dev/project/backend
* Doom Emacs
** Doom
 - path :: ~/.config/doom
Alexander-Miller commented 1 year ago

I have enabled workspaces for Doom Emacs, which means that the treemacs-scope-type is set to Perspectives.

I have no idea what doom does, how and if it interferes with treemacs' features. Try it without doom's integration, and just use treemacs as a normal package. You'll need to also install the right persp package, other than that you can keep most of your config.

(setq treemacs-workspace-switch-cleanup "files")

This should be 'files.

Caliv0 commented 1 year ago

After removing treemacs from my doom init file, and adding it as a separate package, it now works just as it did a month a go.

Exactly how I wanted it to work.

Thanks

chris-johnson-7r commented 9 months ago

@Caliv0 There is an issue for this now open with doom as it appears to be a problem with their workspaces module: https://github.com/doomemacs/doomemacs/issues/7614