Skip to content

Loading…

How can I manually set ctrlp's directory to search on a per project basis? #526

Closed
chevex opened this Issue · 4 comments

3 participants

@chevex

At work I have a "work-code" folder in my home directory. Within that directory there are about five git repositories that are all related. I love how ctrlp travels the directory tree until it finds a .git folder to use as reference. However, in this case I want ctrlp to jump up one directory to "work-code" and search all five of my repositories.

I know that can disable ctrlp's feature to traverse the directory tree looking for .git but I don't want to disable it. I just want to manually specify the ctrlp directory but only in those five projects. Is there a way to tell ctrlp what base directory to use on a per project basis?

@chevex

It would be cool if I could do something simple like drop a .ctrlp file in a project's directory with some simple config stuff in it, like the root directory to use. If that was an option then I could put a .ctrlp file in ~/work-code/project1/.ctrlp and inside that file manually set the root directory to ~/work-code/.

@positron

If you set let g:ctrlp_working_path_mode = 0 it will use the directory you started vim in to search out of. So what I do is just start vim from my root directory with vim ., and then use ctrlp to open the file(s) I want to edit.

@chevex

Interesting. Not quite the ideal solution I was hoping for but I appreciate the reply :)

I've just gone ahead with this for now:

noremap <C-a> :CtrlP ~/work-code/<CR>

So I can do ctrl-a when I want to search all my work code.

I just think it would be so cool to be able to drop .ctrlp files in any directory and add it to list of files/folders to look for when it's traversing up the directory tree. If it finds the file and it's empty then it just uses it as a root marker like it already does. However, if it finds settings inside then it should apply those settings. One of those settings being something like

let g:ctrlp_root_directory = "../"

In my setup this would tell ctrlp to go up one more directory (to my work-code directory).

@kien
Owner

You'll probably have more freedom using a local .vimrc for the project, and put the settings there. If you don't want to do that, a simple mapping to :CtrlP ../ should be suffice, I think.

@kien kien closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.