Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
85 lines (68 sloc) 2.76 KB
" Make ctrl-a search files
nnoremap <C-a> :Files<cr>
"autocmd VimEnter * nnoremap <C-a> :<C-u>Unite -buffer-name=files -prompt-direction=above -start-insert file_rec/async:!<cr>
" maiing for \ag
nnoremap <leader>ag :Ag <C-r><C-w><CR>
" set history directory into normal tmp dir
let g:fzf_history_dir = $HOME . "/.config/nvim/tmp"
" \ur to insert prequire statements
function! Insert_require(path)
let line = system('relativePath.pl ' . a:path . ' 2>/dev/null')
echom 'relativePath.pl ' . a:path . ' ' . expand('%:p') . ' 2>/dev/null'
execute "normal! mqgg}O" . line . "\<esc>`q"
endfunction
command InsertRequire call fzf#run(fzf#wrap('requires', {'sink': function('Insert_require'), 'options': '-q ".js "'}))
map <Leader>ur :InsertRequire<CR>
" \ud to insert drequire statements
function! Insert_require_dynamic(path)
let line = system('relativePath.pl --dynamic ' . a:path . ' 2>/dev/null')
echom 'relativePath.pl --dynamic ' . a:path . ' ' . expand('%:p') . ' 2>/dev/null'
execute "normal! mqgg}O" . line . "\<esc>`q"
endfunction
command InsertRequireDynamic call fzf#run(fzf#wrap('requires', {'sink': function('Insert_require_dynamic'), 'options': '-q ".js "'}))
map <Leader>ud :InsertRequireDynamic<CR>
" \ul to search for the word under the cursor
map <Leader>ul :Ag <C-R><C-W><CR>
" \ug to search to a prompted word
function PromptForSearch()
call inputsave()
let term = input('Search: ')
call inputrestore()
execute "Ag " . term
endfunction
map <Leader>ug :call PromptForSearch()<CR>
function! AgWithDirectory(query, dir)
call fzf#vim#ag(a:query, fzf#vim#with_preview({'dir': a:dir}, 'right:50%'))
endfunction
" Next two are variants on \ug and \ul that prompt for a directory to search
" inside of (\uL and \uG)
function PromptForSearchAndPath()
call inputsave()
let term = input('Search: ')
call inputrestore()
call inputsave()
let dir = input('Directory: ')
call inputrestore()
call AgWithDirectory(term, dir)
endfunction
map <Leader>uG :call PromptForSearchAndPath()<CR>
function PromptForPath(term)
call inputsave()
let dir = input('Directory: ')
call inputrestore()
call AgWithDirectory(a:term, dir)
endfunction
map <Leader>uL :call PromptForPath('<C-R><C-W>')<CR>
" use \uh for help tags search
map <Leader>uh :Helptags<CR>
" use Ctrl-S to search through modified get files
map <C-s> :GFiles?<CR>
command! -nargs=+ -complete=dir AgIn call s:ag_in(<f-args>)
" :Ag - Start fzf with hidden preview window that can be enabled with "?" key
" :Ag! - Start fzf in fullscreen and display the preview window above
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%'),
\ <bang>0)
map <Leader>ub :Buffers<CR>