Add vimrc function for searching specific extensions
This commit is contained in:
parent
173bda9eb0
commit
8ff9c338b5
66
vimrc
66
vimrc
|
@ -1394,38 +1394,78 @@ function! Search(path, search_args, case_insensitive=0)
|
||||||
exec l:cmd
|
exec l:cmd
|
||||||
endfunction
|
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:
|
" Case insensitive:
|
||||||
nnoremap <leader>s :call Search('.', g:campo_custom_search_args, 1)<cr>
|
nnoremap <leader>s :call Search( '.', g:campo_custom_search_args, 1)<cr>
|
||||||
|
nnoremap <leader>sd :call SearchExt('.', g:campo_custom_search_args, 1)<cr>
|
||||||
" Case sensitive:
|
" Case sensitive:
|
||||||
nnoremap <leader>ss :call Search('.', g:campo_custom_search_args)<cr>
|
nnoremap <leader>ss :call Search( '.', g:campo_custom_search_args, 0)<cr>
|
||||||
|
nnoremap <leader>ssd :call SearchExt('.', g:campo_custom_search_args, 0)<cr>
|
||||||
|
|
||||||
"/////////////////////////////////////////////////
|
"/////////////////////////////////////////////////
|
||||||
" SEARCH IN DIRECTORY CONTAINING THE ACTIVE FILE
|
" SEARCH IN DIRECTORY CONTAINING THE ACTIVE FILE
|
||||||
"/////////////////////////////////////////////////
|
"/////////////////////////////////////////////////
|
||||||
|
|
||||||
" Case insensitive:
|
" Case insensitive:
|
||||||
nnoremap <leader>sf :call Search(expand('%:p:h'), g:campo_custom_search_args, 1)<cr>
|
nnoremap <leader>sf :call Search( expand('%:p:h'), g:campo_custom_search_args, 1)<cr>
|
||||||
|
nnoremap <leader>sdf :call SearchExt(expand('%:p:h'), g:campo_custom_search_args, 1)<cr>
|
||||||
" Case sensitive:
|
" Case sensitive:
|
||||||
nnoremap <leader>ssf :call Search(expand('%:p:h'), g:campo_custom_search_args)<cr>
|
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 JAI FOLDERS
|
" SEARCH IN JAI FOLDERS
|
||||||
"/////////////////////////////////////////////////
|
"/////////////////////////////////////////////////
|
||||||
|
|
||||||
" Case insensitive:
|
" Case insensitive:
|
||||||
nnoremap <leader>sg :call Search(g:campo_jai_path, g:campo_custom_search_args, 1)<cr>
|
"
|
||||||
nnoremap <leader>sm :call Search(g:campo_jai_path . '/modules', g:campo_custom_search_args, 1)<cr>
|
" ROOT
|
||||||
nnoremap <leader>sh :call Search(g:campo_jai_path . '/how_to', g:campo_custom_search_args, 1)<cr>
|
nnoremap <leader>sg :call Search( g:campo_jai_path, g:campo_custom_search_args, 1)<cr>
|
||||||
nnoremap <leader>se :call Search(g:campo_jai_path . '/examples', g:campo_custom_search_args, 1)<cr>
|
nnoremap <leader>sdg :call SearchExt(g:campo_jai_path, g:campo_custom_search_args, 1)<cr>
|
||||||
|
" MODULES
|
||||||
|
nnoremap <leader>sm :call Search( g:campo_jai_path.'/modules', g:campo_custom_search_args, 1)<cr>
|
||||||
|
nnoremap <leader>sdm :call SearchExt(g:campo_jai_path.'/modules', g:campo_custom_search_args, 1)<cr>
|
||||||
|
" HOW TO
|
||||||
|
nnoremap <leader>sh :call Search( g:campo_jai_path.'/how_to', g:campo_custom_search_args, 1)<cr>
|
||||||
|
nnoremap <leader>sdh :call SearchExt(g:campo_jai_path.'/how_to', g:campo_custom_search_args, 1)<cr>
|
||||||
|
" EXAMPLES
|
||||||
|
nnoremap <leader>se :call Search( g:campo_jai_path.'/examples', g:campo_custom_search_args, 1)<cr>
|
||||||
|
nnoremap <leader>sde :call SearchExt(g:campo_jai_path.'/examples', g:campo_custom_search_args, 1)<cr>
|
||||||
|
|
||||||
" Case sensitive:
|
" Case sensitive:
|
||||||
nnoremap <leader>ssg :call Search(g:campo_jai_path, g:campo_custom_search_args)<cr>
|
"
|
||||||
nnoremap <leader>ssm :call Search(g:campo_jai_path . '/modules', g:campo_custom_search_args)<cr>
|
" ROOT
|
||||||
nnoremap <leader>ssh :call Search(g:campo_jai_path . '/how_to', g:campo_custom_search_args)<cr>
|
nnoremap <leader>ssg :call Search( g:campo_jai_path, g:campo_custom_search_args, 0)<cr>
|
||||||
nnoremap <leader>sse :call Search(g:campo_jai_path . '/examples', g:campo_custom_search_args)<cr>
|
nnoremap <leader>ssdg :call SearchExt(g:campo_jai_path, g:campo_custom_search_args, 0)<cr>
|
||||||
|
" MODULES
|
||||||
|
nnoremap <leader>ssm :call Search( g:campo_jai_path.'/modules', g:campo_custom_search_args, 0)<cr>
|
||||||
|
nnoremap <leader>ssdm :call SearchExt(g:campo_jai_path.'/modules', g:campo_custom_search_args, 0)<cr>
|
||||||
|
" HOW TO
|
||||||
|
nnoremap <leader>ssh :call Search( g:campo_jai_path.'/how_to', g:campo_custom_search_args, 0)<cr>
|
||||||
|
nnoremap <leader>ssdh :call SearchExt(g:campo_jai_path.'/how_to', g:campo_custom_search_args, 0)<cr>
|
||||||
|
" EXAMPLES
|
||||||
|
nnoremap <leader>sse :call Search( g:campo_jai_path.'/examples', g:campo_custom_search_args, 0)<cr>
|
||||||
|
nnoremap <leader>ssde :call SearchExt(g:campo_jai_path.'/examples', g:campo_custom_search_args, 0)<cr>
|
||||||
|
|
||||||
" Navigation for the vim-ripgrep search results.
|
" Navigation for the vim-ripgrep search results.
|
||||||
" Hit o on a result line to open the file at that line.
|
" Hit o on a result line to open the file at that line.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user