如何根据NerdTree的root更改CtrlP的搜索目录?

时间:2014-02-19 18:12:01

标签: vim ctrlp

我想让我的CtrlP搜索目录在我改变NerdTree根目录的任何时候动态更改。

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

1 个答案:

答案 0 :(得分:24)

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

与此同时,我们留下了逆向工程,阅读源代码,一如既往地,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'
相关问题