diff --git a/.vimrc b/.vimrc index e7c2059..b06e0b4 100644 --- a/.vimrc +++ b/.vimrc @@ -144,6 +144,10 @@ let g:campo_files_to_force_stripping_trailing_whitespace = [] " let g:campo_custom_search_args = \"-g \"!3rd_party/*\" -tc" let g:campo_custom_search_args = "" +" Set to your projects path. Used for scoping search commands to all projects. +" This includes CtrlP. +let g:campo_projects_path = '' + "################################################################################## " CTAGS "################################################################################## @@ -767,11 +771,16 @@ call Cabbrev('WQ', 'call WriteCurrentFileAndCreateCtagsThenQuit()') " Faster way to open a file in the same directory. " will autocomplete the expansion here because we set wildcharm to . nnoremap e :e %:p:h/ -" Jai folders + +" Open a file with the path pre-populated with... +" * Projects folder +nnoremap ep :e =g:campo_projects_path/ +" * Jai folders nnoremap ee :e =g:campo_jai_path/ nnoremap em :e =g:campo_jai_path/modules/ nnoremap eh :e =g:campo_jai_path/how_to/ +" Saving/quitting nnoremap w :call WriteCurrentFileAndCreateCtags() nnoremap x :call WriteCurrentFileAndCreateCtagsThenQuit() nnoremap q :q @@ -900,14 +909,14 @@ fu! CtrlP_Search(search_path) execute 'CtrlP ' . a:search_path endfu -fu! CtrlP_JaiSearch(jai_rel_search_path) - if g:campo_jai_path == '' - call PrintError("g:campo_jai_path isn't set!") +fu! CtrlP_CustomSearch(global_root_path, relative_search_path) + if a:global_root_path == '' + call PrintError("The global root path is empty. See a:global_root_path") return endif - let l:path = g:campo_jai_path - if a:jai_rel_search_path != '' - let l:path .= '/' . a:jai_rel_search_path + let l:path = a:global_root_path + if a:relative_search_path != '' + let l:path .= '/' . a:relative_search_path endif if !isdirectory(l:path) call PrintError("Directory ".l:path." doesn't exist.") @@ -917,11 +926,12 @@ fu! CtrlP_JaiSearch(jai_rel_search_path) endfu " CtrlP File Searching -noremap g :call CtrlP_Search('') " Search in current directory -noremap gg :call CtrlP_JaiSearch('') " Search in Jai directory -noremap gm :call CtrlP_JaiSearch('modules') " Search in Jai modules -noremap gh :call CtrlP_JaiSearch('how_to') " Search in Jai how_to -noremap ge :call CtrlP_JaiSearch('examples') " Search in Jai examples +noremap g :call CtrlP_Search('') " Search in current directory +noremap gp :call CtrlP_CustomSearch(g:campo_projects_path, '') " Search in projects directory. +noremap gg :call CtrlP_CustomSearch(g:campo_jai_path, '') " Search in Jai directory +noremap gm :call CtrlP_CustomSearch(g:campo_jai_path, 'modules') " Search in Jai modules +noremap gh :call CtrlP_CustomSearch(g:campo_jai_path, 'how_to') " Search in Jai how_to +noremap ge :call CtrlP_CustomSearch(g:campo_jai_path, 'examples') " Search in Jai examples " @note we're using a modified version of ctrlp that removes duplicate tags " when using multiple tag files. See https://github.com/sir-pinecone/ctrlp.vim/commit/5cceab @@ -1589,6 +1599,17 @@ nnoremap sdf :call SearchExt(expand('%:p:h'), g:campo_custom_search_arg nnoremap ssf :call Search( expand('%:p:h'), g:campo_custom_search_args, 0) nnoremap ssdf :call SearchExt(expand('%:p:h'), g:campo_custom_search_args, 0) +"///////////////////////////////////////////////// +" SEARCH IN ALL PROJECTS +"///////////////////////////////////////////////// + +" Case insensitive: +nnoremap sp :call Search( g:campo_projects_path, g:campo_custom_search_args, 1) +nnoremap sdp :call SearchExt(g:campo_projects_path, g:campo_custom_search_args, 1) +" Case sensitive: +nnoremap ssp :call Search( g:campo_projects_path, g:campo_custom_search_args, 0) +nnoremap ssdp :call SearchExt(g:campo_projects_path, g:campo_custom_search_args, 0) + "///////////////////////////////////////////////// " SEARCH IN JAI FOLDERS "/////////////////////////////////////////////////