Add vim search commands for personal projects
This commit is contained in:
		
							parent
							
								
									3b6daf46a1
								
							
						
					
					
						commit
						a25c209ddf
					
				
							
								
								
									
										45
									
								
								.vimrc
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								.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.
 | 
			
		||||
" <tab> will autocomplete the expansion here because we set wildcharm to <tab>.
 | 
			
		||||
nnoremap <leader>e :e %:p:h/<tab>
 | 
			
		||||
" Jai folders
 | 
			
		||||
 | 
			
		||||
" Open a file with the path pre-populated with...
 | 
			
		||||
"  * Projects folder
 | 
			
		||||
nnoremap <leader>ep :e <C-r>=g:campo_projects_path<CR>/<tab>
 | 
			
		||||
"  * Jai folders
 | 
			
		||||
nnoremap <leader>ee :e <C-r>=g:campo_jai_path<CR>/<tab>
 | 
			
		||||
nnoremap <leader>em :e <C-r>=g:campo_jai_path<CR>/modules/<tab>
 | 
			
		||||
nnoremap <leader>eh :e <C-r>=g:campo_jai_path<CR>/how_to/<tab>
 | 
			
		||||
 | 
			
		||||
" Saving/quitting
 | 
			
		||||
nnoremap <leader>w :call WriteCurrentFileAndCreateCtags()<cr>
 | 
			
		||||
nnoremap <leader>x :call WriteCurrentFileAndCreateCtagsThenQuit()<cr>
 | 
			
		||||
nnoremap <leader>q :q<cr>
 | 
			
		||||
| 
						 | 
				
			
			@ -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 <leader>g  :call CtrlP_Search('')<cr>            " Search in current directory
 | 
			
		||||
noremap <leader>gg :call CtrlP_JaiSearch('')<cr>         " Search in Jai directory
 | 
			
		||||
noremap <leader>gm :call CtrlP_JaiSearch('modules')<cr>  " Search in Jai modules
 | 
			
		||||
noremap <leader>gh :call CtrlP_JaiSearch('how_to')<cr>   " Search in Jai how_to
 | 
			
		||||
noremap <leader>ge :call CtrlP_JaiSearch('examples')<cr> " Search in Jai examples
 | 
			
		||||
noremap <leader>g  :call CtrlP_Search('')<cr>                                 " Search in current directory
 | 
			
		||||
noremap <leader>gp :call CtrlP_CustomSearch(g:campo_projects_path, '')<cr>    " Search in projects directory.
 | 
			
		||||
noremap <leader>gg :call CtrlP_CustomSearch(g:campo_jai_path, '')<cr>         " Search in Jai directory
 | 
			
		||||
noremap <leader>gm :call CtrlP_CustomSearch(g:campo_jai_path, 'modules')<cr>  " Search in Jai modules
 | 
			
		||||
noremap <leader>gh :call CtrlP_CustomSearch(g:campo_jai_path, 'how_to')<cr>   " Search in Jai how_to
 | 
			
		||||
noremap <leader>ge :call CtrlP_CustomSearch(g:campo_jai_path, 'examples')<cr> " 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 <leader>sdf :call SearchExt(expand('%:p:h'),  g:campo_custom_search_arg
 | 
			
		|||
nnoremap <leader>ssf  :call Search(   expand('%:p:h'), g:campo_custom_search_args, 0)<cr>
 | 
			
		||||
nnoremap <leader>ssdf :call SearchExt(expand('%:p:h'), g:campo_custom_search_args, 0)<cr>
 | 
			
		||||
 | 
			
		||||
"/////////////////////////////////////////////////
 | 
			
		||||
" SEARCH IN ALL PROJECTS
 | 
			
		||||
"/////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
" Case insensitive:
 | 
			
		||||
nnoremap <leader>sp  :call Search(   g:campo_projects_path,  g:campo_custom_search_args, 1)<cr>
 | 
			
		||||
nnoremap <leader>sdp :call SearchExt(g:campo_projects_path,  g:campo_custom_search_args, 1)<cr>
 | 
			
		||||
" Case sensitive:
 | 
			
		||||
nnoremap <leader>ssp  :call Search(   g:campo_projects_path, g:campo_custom_search_args, 0)<cr>
 | 
			
		||||
nnoremap <leader>ssdp :call SearchExt(g:campo_projects_path, g:campo_custom_search_args, 0)<cr>
 | 
			
		||||
 | 
			
		||||
"/////////////////////////////////////////////////
 | 
			
		||||
" SEARCH IN JAI FOLDERS
 | 
			
		||||
"/////////////////////////////////////////////////
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user