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

Add `ag` support to ctrlp and easygrep, clean up

Weiyi Lou 10 лет назад
Родитель
Сommit
8e953df0aa
5 измененных файлов с 62 добавлено и 52 удалено
  1. 14 22
      vim/plugins.vim
  2. 13 9
      vim/settings/ctrlp.vim
  3. 1 0
      vim/settings/delimitMate.vim
  4. 14 9
      vim/settings/easygrep.vim
  5. 20 12
      vim/vimrc

+ 14 - 22
vim/plugins.vim

@@ -10,37 +10,33 @@
 
 
 call plug#begin('~/.vim/plugged')
 call plug#begin('~/.vim/plugged')
 
 
-"if executable('ack-grep')
-  "let g:ackprg="ack-grep -H --nocolor --nogroup --column"
-  "Plug 'mileszs/ack.vim'
-"elseif executable('ack')
-  "Plug 'mileszs/ack.vim'
-"elseif executable('ag')
-  "Plug 'mileszs/ack.vim'
-  "let g:ackprg = 'ag --nogroup --nocolor --column --smart-case'
-"endif
-
+" General {{{
 Plug 'Raimondi/delimitMate'
 Plug 'Raimondi/delimitMate'
-Plug 'altercation/vim-colors-solarized'
+Plug 'dkprice/vim-easygrep'
 Plug 'godlygeek/tabular'
 Plug 'godlygeek/tabular'
 Plug 'haya14busa/vim-asterisk'
 Plug 'haya14busa/vim-asterisk'
-Plug 'itchyny/lightline.vim'
 Plug 'joonty/vdebug'
 Plug 'joonty/vdebug'
-Plug 'kshenoy/vim-signature'
 Plug 'matchit.zip'
 Plug 'matchit.zip'
-Plug 'nathanaelkane/vim-indent-guides'
 Plug 'scrooloose/nerdcommenter'
 Plug 'scrooloose/nerdcommenter'
 Plug 'sjl/gundo.vim'
 Plug 'sjl/gundo.vim'
 Plug 'terryma/vim-multiple-cursors'
 Plug 'terryma/vim-multiple-cursors'
 Plug 'tpope/vim-endwise'
 Plug 'tpope/vim-endwise'
 Plug 'tpope/vim-fugitive'
 Plug 'tpope/vim-fugitive'
 Plug 'tpope/vim-repeat'
 Plug 'tpope/vim-repeat'
-Plug 'tpope/vim-surround'
+" }}}
+
+" Visual {{{
+Plug 'altercation/vim-colors-solarized'
+Plug 'itchyny/lightline.vim'
+Plug 'kshenoy/vim-signature'
+Plug 'nathanaelkane/vim-indent-guides'
+" }}}
 
 
 " Text Objects {{{
 " Text Objects {{{
 Plug 'bkad/CamelCaseMotion'
 Plug 'bkad/CamelCaseMotion'
 Plug 'kana/vim-textobj-entire'
 Plug 'kana/vim-textobj-entire'
 Plug 'kana/vim-textobj-user'
 Plug 'kana/vim-textobj-user'
+Plug 'tpope/vim-surround'
 Plug 'vim-scripts/argtextobj.vim'
 Plug 'vim-scripts/argtextobj.vim'
 " }}}
 " }}}
 
 
@@ -66,25 +62,21 @@ Plug 'ajh17/VimCompletesMe'
 " Coding Language Support {{{
 " Coding Language Support {{{
 Plug 'LnL7/vim-nix'
 Plug 'LnL7/vim-nix'
 Plug 'elzr/vim-json'
 Plug 'elzr/vim-json'
-Plug 'groenewege/vim-less'
-Plug 'kchmck/vim-coffee-script'
-Plug 'mintplant/vim-literate-coffeescript'
-Plug 'quentindecock/vim-cucumber-align-pipes'
 Plug 'scrooloose/syntastic'
 Plug 'scrooloose/syntastic'
-Plug 'shawncplus/phpcomplete.vim'
-Plug 'tpope/vim-cucumber'
-Plug 'tpope/vim-markdown'
+Plug 'sheerun/vim-polyglot'
 Plug 'vim-scripts/yaml.vim'
 Plug 'vim-scripts/yaml.vim'
 " }}}
 " }}}
 
 
 " Games. Why not {{{
 " Games. Why not {{{
 Plug 'katono/rogue.vim'
 Plug 'katono/rogue.vim'
+Plug 'jmanoel7/vim-games'
 " }}}
 " }}}
 
 
 " Discarded {{{
 " Discarded {{{
 "Plug 'deris/vim-shot-f' - interferes with macro
 "Plug 'deris/vim-shot-f' - interferes with macro
 "Plug 'haya14busa/incsearch.vim' - interferes with macros
 "Plug 'haya14busa/incsearch.vim' - interferes with macros
 "Plug 'scrooloose/nerdtree' - moved away from drawer-style browser to netrw.
 "Plug 'scrooloose/nerdtree' - moved away from drawer-style browser to netrw.
+"Plug 'terryma/vim-expand-region' - cool, but often slower than text objects.
 "
 "
 "Plug 'MarcWeber/vim-addon-mw-utils' -\
 "Plug 'MarcWeber/vim-addon-mw-utils' -\
 "Plug 'ervandew/supertab' ------------|
 "Plug 'ervandew/supertab' ------------|

+ 13 - 9
vim/settings/ctrlp.vim

@@ -1,15 +1,19 @@
 let g:ctrlp_map = '<Leader>p'
 let g:ctrlp_map = '<Leader>p'
 
 
-"let g:ctrlp_working_path_mode = 'rw' let's try out ra
-let g:ctrlp_user_command = {
-    \ 'types': {
-        \ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
-        \ 2: ['.hg', 'hg --cwd %s locate -I .'],
-    \ },
-    \ 'fallback': 'find %s -type f'
-\ }
+" Use `ag` as fallback if available.
+if executable('ag')
+  let s:fallback = 'ag %s -l --nocolor -g ""'
+else
+  let s:fallback = 'find %s -type f'
+endif
+
+let g:ctrlp_user_command = [
+  \ '.git',
+  \ 'cd %s && git ls-files . -co --exclude-standard',
+  \ s:fallback
+\]
 
 
 let g:ctrlp_extensions = ['funky']
 let g:ctrlp_extensions = ['funky']
 
 
-" Function definition jumping with CtrlP's Funky plugin
+" Function definition jumping with CtrlP's Funky plugin.
 nnoremap <silent> <Leader>f :CtrlPFunky<CR>
 nnoremap <silent> <Leader>f :CtrlPFunky<CR>

+ 1 - 0
vim/settings/delimitMate.vim

@@ -0,0 +1 @@
+let g:delimitMate_expand_cr = 1

+ 14 - 9
vim/settings/easygrep.vim

@@ -1,14 +1,19 @@
-" 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
+" use faster search tools if available
+if executable('ag')
+  set grepprg=ag\ --vimgrep\ $*
+  set grepformat=%f:%l:%c:%m
+elseif executable('ack')
+  set grepprg=ack\ --with-filename\ --nocolor\ --nogroup\ --column
+elseif executable('ack-grep')
+  set grepprg=ack-grep\ --with-filename\ --nocolor\ --nogroup\ --column
+endif
 
 
 " don't display ack/grep terminal output. NOTE: not reliable
 " don't display ack/grep terminal output. NOTE: not reliable
 " https://github.com/mileszs/ack.vim/issues/18
 " https://github.com/mileszs/ack.vim/issues/18
 "set shellpipe=&>
 "set shellpipe=&>
 
 
-"let g:EasyGrepRecursive = 1
-"let g:EasyGrepHighlightQfMatches = 1
-"let g:EasyGrepReplaceWindowMode = 2  " Edit and save in place (no new tabs/splits)
+let g:EasyGrepCommand = 1            " Default to grepprg instead of vimgrep.
+let g:EasyGrepRecursive = 1
+let g:EasyGrepReplaceWindowMode = 2  " `Replace` in same window, not tabs/splits
+let g:EasyGrepFilesToExclude=".git"  " Exclude dirs for `ack` and `grep`
+let g:EasyGrepRoot = "search:.git,.hg,.svn"  " Repo-aware when possible.

+ 20 - 12
vim/vimrc

@@ -4,6 +4,13 @@ set nocompatible
 " Clear all existing autocommands first to avoid unwanted side effects
 " Clear all existing autocommands first to avoid unwanted side effects
 if has("autocmd")
 if has("autocmd")
   autocmd!
   autocmd!
+  " Automatically detect file types.
+  filetype plugin indent on
+endif
+
+" Syntax highlighting.
+if has("syntax")
+  syntax enable
 endif
 endif
 
 
 " Register plugins
 " Register plugins
@@ -11,12 +18,6 @@ if filereadable(expand("~/dotfiles/vim/plugins.vim"))
   source ~/dotfiles/vim/plugins.vim
   source ~/dotfiles/vim/plugins.vim
 endif
 endif
 
 
-" Automatically detect file types.
-filetype plugin indent on
-
-" Syntax highlighting.
-syntax on
-
 """"""""
 """"""""
 "" Tabs and Text Formatting
 "" Tabs and Text Formatting
 """"""""""""""""""""""""""""""""""""""""""""""""""""""
 """"""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -33,27 +34,28 @@ set textwidth=80   " try to keep text within 80 characters
 set colorcolumn=+1 " mark out the limits of the textwidth
 set colorcolumn=+1 " mark out the limits of the textwidth
 set hidden         " allow changing buffers without unsaved-warnings e.g. for argdo
 set hidden         " allow changing buffers without unsaved-warnings e.g. for argdo
 
 
-set nojoinspaces               " Prevents inserting two spaces after punctuation on a join (J)
 set splitright                 " Puts new vsplit windows to the right of the current
 set splitright                 " Puts new vsplit windows to the right of the current
 set splitbelow                 " Puts new split windows to the bottom of the current
 set splitbelow                 " Puts new split windows to the bottom of the current
 set backspace=indent,eol,start " Backspace for dummies
 set backspace=indent,eol,start " Backspace for dummies
 set linespace=0                " No extra spaces between rows
 set linespace=0                " No extra spaces between rows
-set number                     " Line numbers on
-set relativenumber
+set relativenumber             " Show line numbers relative to current line, and
+set number                     " Show the actual line number on current line.
 set showmatch                  " Show matching brackets/parenthesis
 set showmatch                  " Show matching brackets/parenthesis
 set incsearch                  " Find as you type search
 set incsearch                  " Find as you type search
 set hlsearch                   " Highlight search terms
 set hlsearch                   " Highlight search terms
-set winminheight=0             " Windows can be 0 line high
 set ignorecase                 " Case insensitive search
 set ignorecase                 " Case insensitive search
 set smartcase                  " Case sensitive when uc present
 set smartcase                  " Case sensitive when uc present
+set winminheight=0             " Windows can be 0 line high
 set wildmenu                   " Show list instead of just completing
 set wildmenu                   " Show list instead of just completing
 set modeline                   " Support vim modelines at the top of files
 set modeline                   " Support vim modelines at the top of files
 set whichwrap=b,s,h,l,<,>,[,]  " Backspace and cursor keys wrap too
 set whichwrap=b,s,h,l,<,>,[,]  " Backspace and cursor keys wrap too
 set shortmess+=filmnrxoOtT     " Abbrev. of messages (avoids 'hit enter')
 set shortmess+=filmnrxoOtT     " Abbrev. of messages (avoids 'hit enter')
-set scrolloff=5                " Minimum lines to keep above and below cursor
+set scrolloff=10               " Minimum lines to keep above and below cursor
+set sidescroll=1
+set sidescrolloff=15
 
 
 set list
 set list
-set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
+set listchars=tab:>\ ,trail:.,extends:#,nbsp:#
 
 
 if has('persistent_undo')
 if has('persistent_undo')
   set undofile                " So is persistent undo ...
   set undofile                " So is persistent undo ...
@@ -61,6 +63,12 @@ if has('persistent_undo')
   set undoreload=10000        " Maximum number lines to save for undo on a buffer reload
   set undoreload=10000        " Maximum number lines to save for undo on a buffer reload
 endif
 endif
 
 
+" Join (J) options
+set nojoinspaces        " Prevents inserting two spaces after punctuation
+if v:version > 703 || v:version == 703 && has("patch541")
+  set formatoptions+=j  " Remove comment characters when joining comment lines.
+endif
+
 """"""""
 """"""""
 "" Key Remaps
 "" Key Remaps
 """"""""""""""""""""""""""""""""""""""""""""""""""""""
 """"""""""""""""""""""""""""""""""""""""""""""""""""""