Просмотр исходного кода

update vimrc to allow easygrep to use ack

This in conjunction with the update of EasyGrep to 1.1 that allows better for
ack usage. Will update EasyGrep submodule when our own changes have been
reworked into 1.1.
Weiyi Lou 12 лет назад
Родитель
Сommit
cf8df3bda9
1 измененных файлов с 26 добавлено и 10 удалено
  1. 26 10
      vim/vimrc

+ 26 - 10
vim/vimrc

@@ -27,7 +27,7 @@ set splitright    " New splits appear right of current window
 set ttyfast       " Smooth movement
 set ttyfast       " Smooth movement
 set ttymouse=xterm2
 set ttymouse=xterm2
 set mouse=a
 set mouse=a
-set scrolloff=10  " keep distance from top and bottom for current line
+set scrolloff=7  " keep distance from top and bottom for current line
 set cursorline    " ensure that there is a cursor line
 set cursorline    " ensure that there is a cursor line
 
 
 " Persistent undo
 " Persistent undo
@@ -53,9 +53,6 @@ if has("autocmd")
   " Any actions on startup
   " Any actions on startup
   autocmd VimEnter * call StartUp()
   autocmd VimEnter * call StartUp()
 
 
-  autocmd WinEnter * setlocal cursorline
-  autocmd WinLeave * setlocal nocursorline
-
   " Show trailing white space
   " Show trailing white space
   autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
   autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
   autocmd InsertLeave * match ExtraWhitespace /\s\+$/
   autocmd InsertLeave * match ExtraWhitespace /\s\+$/
@@ -63,14 +60,15 @@ if has("autocmd")
   " Source the vimrc file after saving it
   " Source the vimrc file after saving it
   autocmd BufWritePost .vimrc source $MYVIMRC
   autocmd BufWritePost .vimrc source $MYVIMRC
 
 
-  " Local remaps for Quickfix buffer
+  " Things for Quickfix buffers
+
+  " Local remaps for all Quickfix buffers
   autocmd FileType qf nnoremap <silent> <buffer> q :ccl<CR>:lcl<CR>
   autocmd FileType qf nnoremap <silent> <buffer> q :ccl<CR>:lcl<CR>
   autocmd FileType qf nnoremap <silent> <buffer> o <CR>
   autocmd FileType qf nnoremap <silent> <buffer> o <CR>
-  " TODO this doesn't always return to the window in more complex layouts
-  autocmd FileType qf nnoremap <silent> <buffer> go <CR><C-W><C-W>
 
 
-  " Global remaps when QuickFix buffer is opened
+  " Global remaps for all QuickFix buffers
   autocmd BufWinEnter quickfix
   autocmd BufWinEnter quickfix
+        \ setlocal nocursorline |
         \ let g:qfix_win = bufnr("$") |
         \ let g:qfix_win = bufnr("$") |
         \ call MapQfPrevNext()
         \ call MapQfPrevNext()
   autocmd BufWinLeave *
   autocmd BufWinLeave *
@@ -80,10 +78,17 @@ if has("autocmd")
         \ endif
         \ endif
 
 
   " Open QuickFix window after any grep invocation (Glog and Ggrep)
   " Open QuickFix window after any grep invocation (Glog and Ggrep)
-  autocmd QuickFixCmdPost *grep* cwindow | call MapQfPrevNext()
+  autocmd QuickFixCmdPost *grep* cwindow |
+        \ setlocal nocursorline |
+        \ let g:qfix_win = bufnr("$") |
+        \ call MapQfPrevNext()
 
 
   " if the last window is NERDTree, then close Vim
   " if the last window is NERDTree, then close Vim
   "autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
   "autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
+  "
+  " Show cursorline only on active window. No need for this now
+  "autocmd WinEnter * setlocal cursorline
+  "autocmd WinLeave * setlocal nocursorline
 else
 else
   set autoindent on
   set autoindent on
 endif
 endif
@@ -159,6 +164,14 @@ set incsearch   " vim will search as you type!
 set ignorecase  " ignore case for searches
 set ignorecase  " ignore case for searches
 set smartcase   " well, unless a user puts in uppercase search characters
 set smartcase   " well, unless a user puts in uppercase search characters
 set magic       " enables wildcard searching
 set magic       " enables wildcard searching
+" use ack for grepping if available
+if executable('ack-grep')
+  set grepprg=ack-grep\ --with-filename\ --nocolor\ --nogroup
+elseif executable('ack')
+  set grepprg=ack\ --with-filename\ --nocolor\ --nogroup
+endif
+set shellpipe=&>  " don't display ack/grep terminal output. NOTE: not reliable
+                  " https://github.com/mileszs/ack.vim/issues/18
 
 
 
 
 """"""""
 """"""""
@@ -224,6 +237,9 @@ nmap <silent> <leader>u    :GundoToggle<CR>
 nmap <silent> <leader>b    :Gblame<CR>
 nmap <silent> <leader>b    :Gblame<CR>
 nmap <silent> <leader>g    :Glog<CR><CR>
 nmap <silent> <leader>g    :Glog<CR><CR>
 
 
+" Ack with Ctrl-F
+nmap <C-F> :Grep<space>
+
 " Code heirarchy with Tagbar
 " Code heirarchy with Tagbar
 nmap <silent> <leader>t    :TagbarToggle<CR>
 nmap <silent> <leader>t    :TagbarToggle<CR>
 
 
@@ -278,7 +294,7 @@ let g:tagbar_autoclose = 1 " close sidebar after we go to selection
 
 
 
 
 """"""""" EasyGrep
 """"""""" EasyGrep
-let g:EasyGrepJumpToMatch = 0
+let g:EasyGrepCommand = 1 " don't use the built in vimgrep, which is slow
 let g:EasyGrepHighlightQfMatches = 1
 let g:EasyGrepHighlightQfMatches = 1