How to make CtrlP's search directory change according to NerdTree's root?
Asked Answered
E

1

12

I want my CtrlP search directory to dynamically change anytime I change NerdTree's root directory.

How does plugin to plugin communication work in vim?

Emilie answered 19/2, 2014 at 18:12 Comment(0)
R
27

It doesn't work at all. Vim simply doesn't expose the common interface that would help plugin authors make their plugins work seamlessly together. Maybe one day…

In the mean time, we are left with reverse engineering, reading source code and, as always, RTFM.

NERDTree's NERDTreeChDirMode option that dictates the plugin's behavior with regard to changing Vim's "current directory":

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.

On CtrlP's side, the ctrlp_working_path_mode option sounds interesting:

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.

So it looks like the two options below will give you what you want:

let g:NERDTreeChDirMode       = 2
let g:ctrlp_working_path_mode = 'rw'
Reviviscence answered 19/2, 2014 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.