My root project directory has the following:
root/
.git
Assets
Library
obj
Temp
etc.
Ctrlp by default looks in this root directory. I want to set the directory it starts looking in to "Assets". I looked at the docs and read in a few links that I should use ctrlp_root_markers
, so in my vimrc
:
let g:ctrlp_root_markers = ['Assets']
But then calling Ctrlp in vim while I'm in any source file under Assets, it always starts its indexing/search from the root
directory. It just ignores the values I set in the root markers list. (I also tried messing with ctrlp_working_path_mode
)
I ended up using this function (which I found lurking SO):
function! FindProjectRoot(lookFor)
let pathMaker='%:p'
while(len(expand(pathMaker))>len(expand(pathMaker.':h')))
let pathMaker=pathMaker.':h'
let fileToCheck=expand(pathMaker).'/'.a:lookFor
if filereadable(fileToCheck)||isdirectory(fileToCheck)
return expand(pathMaker).'/'.a:lookFor
endif
endwhile
return 0
endfunction
And then remapping C-p:
nnoremap <C-p> :CtrlP `=FindProjectRoot("Assets")`<CR>
Works fine. But if a feature should be included in the core plugin I feel it's redundant to have to work-around it.
Any ideas what I'm doing wrong in setting my root markers?
Appreciate any help!