Browse Source

Revert "Replace unite with ctrlp"

This reverts commit 353fb42103cf5ad355cd693330885975faa42e7d.
Thomas Dy 8 years ago
parent
commit
68350dd794
2 changed files with 22 additions and 6 deletions
  1. 4 0
      .vim/ag-unite
  2. 18 6
      .vimrc

+ 4 - 0
.vim/ag-unite

@@ -0,0 +1,4 @@
+#!/bin/sh
+cd $1
+touch /tmp/a
+ag --hidden --nocolor --nogroup -g ''

+ 18 - 6
.vimrc

@@ -8,7 +8,7 @@ Plug 'bling/vim-airline'
 Plug 'mhinz/vim-signify'
 Plug 'mhinz/vim-grepper'
 Plug 'sjl/gundo.vim'
-Plug 'ctrlpvim/ctrlp.vim'
+Plug 'Shougo/unite.vim'
 Plug 'EinfachToll/DidYouMean'
 
 Plug 'vim-scripts/dbext.vim', {'for': 'sql'}
@@ -50,13 +50,22 @@ let g:signify_vcs_list = [ 'git' ]
 
 let g:jsx_ext_required = 0
 
+call unite#filters#matcher_default#use(['matcher_fuzzy'])
+
+" use ag if present
 if executable('ag')
-  " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
-  " we cd first into the dir so ag will use .agignore correctly
-  let g:ctrlp_user_command = 'cd %s && ag --nocolor --hidden -g ""'
+  " we run a wrapper around ag so it respects agignore
+  let g:unite_source_rec_async_command = ['sh', expand('~/.vim/ag-unite')]
   let g:grepper = { 'tools': ['ag', 'git', 'grep'] }
 endif
 
+autocmd FileType unite call s:unite_settings()
+function! s:unite_settings()
+  " Enable navigation with control-j and control-k in insert mode
+  imap <buffer> <C-j>   <Plug>(unite_select_next_line)
+  imap <buffer> <C-k>   <Plug>(unite_select_previous_line)
+endfunction
+
 " ------ settings ------
 
 " change terminal title
@@ -115,8 +124,9 @@ nnoremap k gk
 vnoremap j gj
 vnoremap k gk
 
-" opening ctrlp
-nnoremap <C-O> :CtrlPBuffer<cr>
+" opening unite
+nnoremap <C-P> :Unite -no-split -buffer-name=files -start-insert file_rec<cr>
+nnoremap <C-O> :Unite -no-split -buffer-name=buffers -start-insert buffer<cr>
 
 imap <C-W> <ESC><C-W>
 nnoremap <C-T>h :tabprev<cr>
@@ -144,6 +154,8 @@ if has('nvim')
   tnoremap <C-V><C-V> <C-V>
   tnoremap <C-V> <C-\><C-N>"+pi
 
+  nnoremap <C-P> :Unite -no-split -buffer-name=files -start-insert file_rec/neovim<cr>
+
   autocmd BufWinEnter,WinEnter term://* startinsert
 endif