diff --git a/vimrc b/vimrc index a22a04c..b4a9e82 100644 --- a/vimrc +++ b/vimrc @@ -1394,38 +1394,78 @@ function! Search(path, search_args, case_insensitive=0) exec l:cmd endfunction +function! SearchExt(path, search_args, case_insensitive=0) + call inputsave() + let l:ext = input('Enter extension to search on (leave blank for files with no ext): ') + call inputrestore() + redraw! + + if empty(l:ext) + let l:ext = "!*.*" + else + let l:ext = "*.".l:ext + endif + + let l:args = a:search_args." -g \"".l:ext."\"" + + call Search(a:path, l:args, a:case_insensitive) +endfunction + "///////////////////////////////////////////////// -" SEARCH IN CURRENT DIRECTORY +" SEARCH IN CURRENT WORKING DIRECTORY "///////////////////////////////////////////////// " Case insensitive: -nnoremap s :call Search('.', g:campo_custom_search_args, 1) +nnoremap s :call Search( '.', g:campo_custom_search_args, 1) +nnoremap sd :call SearchExt('.', g:campo_custom_search_args, 1) " Case sensitive: -nnoremap ss :call Search('.', g:campo_custom_search_args) +nnoremap ss :call Search( '.', g:campo_custom_search_args, 0) +nnoremap ssd :call SearchExt('.', g:campo_custom_search_args, 0) "///////////////////////////////////////////////// " SEARCH IN DIRECTORY CONTAINING THE ACTIVE FILE "///////////////////////////////////////////////// " Case insensitive: -nnoremap sf :call Search(expand('%:p:h'), g:campo_custom_search_args, 1) +nnoremap sf :call Search( expand('%:p:h'), g:campo_custom_search_args, 1) +nnoremap sdf :call SearchExt(expand('%:p:h'), g:campo_custom_search_args, 1) " Case sensitive: -nnoremap ssf :call Search(expand('%:p:h'), g:campo_custom_search_args) +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 JAI FOLDERS "///////////////////////////////////////////////// " Case insensitive: -nnoremap sg :call Search(g:campo_jai_path, g:campo_custom_search_args, 1) -nnoremap sm :call Search(g:campo_jai_path . '/modules', g:campo_custom_search_args, 1) -nnoremap sh :call Search(g:campo_jai_path . '/how_to', g:campo_custom_search_args, 1) -nnoremap se :call Search(g:campo_jai_path . '/examples', g:campo_custom_search_args, 1) +" +" ROOT +nnoremap sg :call Search( g:campo_jai_path, g:campo_custom_search_args, 1) +nnoremap sdg :call SearchExt(g:campo_jai_path, g:campo_custom_search_args, 1) +" MODULES +nnoremap sm :call Search( g:campo_jai_path.'/modules', g:campo_custom_search_args, 1) +nnoremap sdm :call SearchExt(g:campo_jai_path.'/modules', g:campo_custom_search_args, 1) +" HOW TO +nnoremap sh :call Search( g:campo_jai_path.'/how_to', g:campo_custom_search_args, 1) +nnoremap sdh :call SearchExt(g:campo_jai_path.'/how_to', g:campo_custom_search_args, 1) +" EXAMPLES +nnoremap se :call Search( g:campo_jai_path.'/examples', g:campo_custom_search_args, 1) +nnoremap sde :call SearchExt(g:campo_jai_path.'/examples', g:campo_custom_search_args, 1) + " Case sensitive: -nnoremap ssg :call Search(g:campo_jai_path, g:campo_custom_search_args) -nnoremap ssm :call Search(g:campo_jai_path . '/modules', g:campo_custom_search_args) -nnoremap ssh :call Search(g:campo_jai_path . '/how_to', g:campo_custom_search_args) -nnoremap sse :call Search(g:campo_jai_path . '/examples', g:campo_custom_search_args) +" +" ROOT +nnoremap ssg :call Search( g:campo_jai_path, g:campo_custom_search_args, 0) +nnoremap ssdg :call SearchExt(g:campo_jai_path, g:campo_custom_search_args, 0) +" MODULES +nnoremap ssm :call Search( g:campo_jai_path.'/modules', g:campo_custom_search_args, 0) +nnoremap ssdm :call SearchExt(g:campo_jai_path.'/modules', g:campo_custom_search_args, 0) +" HOW TO +nnoremap ssh :call Search( g:campo_jai_path.'/how_to', g:campo_custom_search_args, 0) +nnoremap ssdh :call SearchExt(g:campo_jai_path.'/how_to', g:campo_custom_search_args, 0) +" EXAMPLES +nnoremap sse :call Search( g:campo_jai_path.'/examples', g:campo_custom_search_args, 0) +nnoremap ssde :call SearchExt(g:campo_jai_path.'/examples', g:campo_custom_search_args, 0) " Navigation for the vim-ripgrep search results. " Hit o on a result line to open the file at that line.