weirongxu / coc-explorer

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

The root directory changed unexpectly. Please help!!! #447

Closed ysl2 closed 3 years ago

ysl2 commented 3 years ago

Hello, I tried my best to figure out which setting could achieve my expection but failed.

I want to use i and I to change my root directory (and pwd), and the root will not be auto modified. But now when I open a file, my directory auto changed.

This is part of my personal setting items relative to the directory settings.

I would be very appreciate if you could help me, Thanks :-)

// jump into & jump out
"i": ["wait", "expandable?", "expand", "cd", "open"],
"I": ["wait", "gotoParent"],
weirongxu commented 3 years ago
"i": ["wait", "expandable?", "cd", "open"],
"I": ["wait", "gotoParent"],
ysl2 commented 3 years ago

@weirongxu 老哥,原来您是中国的,太好了,我英语不太行,刚才我没说明白

我现在的状况是:

  1. iI能正常的进入目录和退出目录,但是我在shell下的位置依然始终在原地没动(一直保持在vim打开时的路径)。我想让我当前在shell下的路径也跟着iI变化。

  2. 通过explorer打开某个文件以后,如果收缩explorer再重新展开explorer,我当前在explorer里的路径会直接跟随到当前打开文件的位置。我想始终保持在explorer的项目位置,而不是这种跟随的方式。

上述过程中,我在shell下的路径始终没改变。

我想达到的效果:

  1. explorer的根目录只与iI有关,与当前打开文件的动作无关。

  2. 在通过按iI改变explorer的根路径的时候,我在当前shell下的路径也会跟着一起变化。

多谢老哥帮忙,谢谢 :-)


The current status:

1, I can change directory normally by i and I, but the real directory in shell still keep in the path where I open vim. I want my shell path changed together with explorer.

  1. After opening a file by explorer, If I hide explorer and reopen it, the directory in explorer will follow to goto the current file location. I prefer keeping in explorer rather than this following.

My shell path still in the path where I open vim.

The expection I want:

  1. The root directory in explorer is only relative with i and I, insted of the open-file motion.

  2. The shell path will automatically changed then pressing i and I

Thanks for your help :-)

weirongxu commented 3 years ago

按i和I能正常的进入目录和退出目录,但是我在shell下的位置依然始终在原地没动(一直保持在vim打开时的路径)。我想让我当前在shell下的路径也跟着i和I变化。

这应该是 shell 的限制,我没找到办法在 vim 里修改 shell 的工作目录

通过explorer打开某个文件以后,如果收缩explorer再重新展开explorer,我当前在explorer里的路径会直接跟随到当前打开文件的位置。我想始终保持在explorer的项目位置,而不是这种跟随的方式。

收缩展开 explorer 不会跟随文件,你可能指的是 打开关闭

CocCommand explorer --root-strategies keep

"explorer.file.revealWhenOpen": false
ysl2 commented 3 years ago

@weirongxu 老哥,我现在有点事,出门了。刚才在一边走一边看,我发现一条下面这个coc-json设置,不知道能不能用这个达到切换shell目录的效果?

explorer.file.cdCommand: "cd"

weirongxu commented 3 years ago

@weirongxu 老哥,我现在有点事,出门了。刚才在一边走一边看,我发现一条下面这个coc-json设置,不知道能不能用这个达到切换shell目录的效果?

explorer.file.cdCommand: "cd"

这个是切换 vim 内部的 cwd 目录 :help pwd

ysl2 commented 3 years ago

老哥,刚才问题解决了。我的设置如下:

init.vim
=====

nmap <silent> \e :CocCommand explorer --root-strategies reveal<CR>
coc-settings.json
=============

"explorer.file.showHiddenFiles": false,
"explorer,file.cdCommand": "cd",

"explorer.keyMappings.global": {
  "i": ["wait", "expandable?", "cd", "open"],
  "I": ["wait", "gotoParent"],
}