weirongxu / coc-explorer

📁 Explorer for coc.nvim
MIT License
1.14k stars 45 forks source link

PWD isn't respected for some files #471

Closed farzadmf closed 3 years ago

farzadmf commented 3 years ago

Hi,

I've set my config so that when I open coc-explorer, it focues the file in the tree, however, it seems to ignore the current working directory (pwd) when opening some files.

This is the scenario:

  1. Let's say I have a root git directory in /home/farzad/mydir.
  2. I go to /home/farzad/mydir/level/one and I open nvim
  3. If my buffer is /home/.../level/one/my.go, when I open coc-explorer, it properly expands /home/.../level/one directory (which is the directory reported by :pwd as well)
  4. However, when I open /home/.../level/one/my.rb, when I open coc-explorer, it expands /home/farzad/mydir (the root git directory), not respecting the :pwd

Is there something wrong with my config?

Thank you in advance


UPDATE: this doesn't seem to be consistent either, even for .rb files, sometimes it opens the current directory and sometimes it opens the root git directory, so I'm not exactly sure what's happening

weirongxu commented 3 years ago

You can try changing the root-strategies to ["cwd"], default is

[
"workspace",
"cwd",
"sourceBuffer",
"reveal"
]

https://github.com/weirongxu/coc-explorer#--root-strategies-root-strategies

weirongxu commented 3 years ago

For some files, workspace.root is empty because LSP did not resolve workspace.root

farzadmf commented 3 years ago

Thank you @weirongxu for the answer, I'll try your suggestions and update here with the results :+1: