Skip to content

Commit

Permalink
use fzf instead of ctrl-p
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-plated committed Jun 16, 2016
1 parent 0833222 commit 8af0ae3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
2 changes: 2 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
tap 'thoughtbot/formulae'
brew 'rcm'
brew 'fzf'
brew 'the_silver_searcher'
54 changes: 22 additions & 32 deletions vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ if count(g:vimified_packages, 'general')
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-vinegar'

Plugin 'rking/ag.vim'
function! AgGrep()
let command = 'ag -i '.expand('<cword>')
cexpr system(command)
cw
endfunction

function! AgVisual()
normal gv"xy
let command = 'ag -i '.@x
cexpr system(command)
cw
endfunction

map <leader>a :call AgGrep()<CR>
vmap <leader>a :call AgVisual()<CR>
Plugin 'tpope/vim-surround'
" Add $ as a jQuery surround, _ for Underscore.js
autocmd FileType javascript let b:surround_36 = "$(\r)"
Expand All @@ -84,25 +67,32 @@ if count(g:vimified_packages, 'general')
map \ :NERDTreeToggle<CR>
map \| :NERDTreeFind<CR>
Plugin 'ctrlpvim/ctrlp.vim'
let g:ctrlp_match_window = 'bottom,order:ttb,min:1,max:10,results:10'
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_max_files = 0
Plugin 'junegunn/fzf'
let $FZF_DEFAULT_COMMAND= 'ag -g ""'
nnoremap <C-p> :FZF<CR>
nnoremap <silent> <leader>f :FZF<CR>
nnoremap <silent> <leader>f :CtrlP<CR>
noremap <leader>b :CtrlPBuffer<CR>

Plugin 'FelikZ/ctrlp-py-matcher'
let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' }
Plugin 'junegunn/fzf.vim'
let g:fzf_layout = {'down': '40%'}
let g:fzf_tags_command = 'ripper-tags -R'
noremap <leader>b :Buffers<CR>
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
map <leader>a :call fzf#vim#ag(expand('<cword>'), fzf#vim#layout())<CR>
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --ignore ".git" --ignore ".DS_Store" --hidden -g ""'
else
nnoremap <silent> <leader>F :ClearCtrlPCache<CR>\|:CtrlP<CR>
endif
function! s:get_visual_selection()
" Why is this not a built-in Vim script function?!
let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2]
let lines = getline(lnum1, lnum2)
let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)]
let lines[0] = lines[0][col1 - 1:]
return join(lines, "\n")
endfunction

command -range AgVisual call fzf#vim#ag(s:get_visual_selection(), fzf#vim#layout())

vmap <leader>a :AgVisual<CR>
" File Renaming (credit: garybernhardt)
function! RenameFile()
Expand Down

0 comments on commit 8af0ae3

Please sign in to comment.