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

11
我希望我的CtrlP搜索目录能够在我改变NerdTree的根目录时动态更改。
在vim中,插件间通信是如何工作的?
1个回答

26

完全不起作用。 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'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接