11

我希望我的 CtrlP 搜索目录在我更改 NerdTree 的根目录时动态更改。

插件到插件的通信如何在 vim 中工作?

4

1 回答 1

26

它根本不起作用。Vim 根本没有公开可以帮助插件作者使他们的插件无缝协同工作的通用接口。也许有一天……</p>

与此同时,我们还剩下逆向工程、阅读源代码以及一如既往的 RTFM。

NERDTree 的NERDTreeChDirMode选项规定插件在更改 Vim 的“当前目录”时的行为:

If the option is set to 2 then it behaves the same as if set to 1 except that
the CWD is changed whenever the tree root is changed. For example, if the CWD
is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
root then the CWD will become /home/marty/foobar/baz.

在 CtrlP 方面,这个ctrlp_working_path_mode选项听起来很有趣:

w - begin finding a root from the current working directory outside of CtrlP
    instead of from the directory of the current file (default). Only applies
    when "r" is also present.

所以看起来下面的两个选项会给你你想要的:

let g:NERDTreeChDirMode       = 2
let g:ctrlp_working_path_mode = 'rw'
于 2014-02-19T19:59:51.670 回答