Skip to content

Commit

Permalink
Without pattern arg use word under cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
lucerion committed Jul 16, 2016
1 parent 37462db commit 7bec8cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions autoload/ctrlp/grep.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" Description: CtrlP grep extension
" Author: Alexander Skachko <alexander.skachko@gmail.com>
" Homepage: https://github.com/lucerion/ctrlp-grep
" Version: 1.0
" Version: 1.1
" Licence: BSD-3-Clause
" ==============================================================

Expand All @@ -19,9 +19,10 @@ call add(g:ctrlp_ext_vars, {
\ 'type': 'line'
\ })

func! ctrlp#grep#run(pattern, ...)
let l:dirs = empty(a:000) ? '.' : join(a:000)
let s:result = system(g:ctrlp_grep_command . ' ' . a:pattern . ' ' . l:dirs)
func! ctrlp#grep#run(...)
let l:pattern = get(a:000, 0, expand('<cword>'))
let l:dirs = a:0 > 1 ? join(a:000[1:-1]) : '.'
let s:result = system(g:ctrlp_grep_command . ' ' . l:pattern . ' ' . l:dirs)
call ctrlp#init(ctrlp#grep#id())
endfunc

Expand Down
4 changes: 2 additions & 2 deletions plugin/ctrlp-grep.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
" Description: CtrlP grep extension
" Author: Alexander Skachko <alexander.skachko@gmail.com>
" Homepage: https://github.com/lucerion/ctrlp-grep
" Version: 1.0
" Version: 1.1
" Licence: BSD-3-Clause
" ==============================================================

if !exists('g:ctrlp_grep_command')
let g:ctrlp_grep_command = 'grep -rins'
endif

comm! -nargs=+ -complete=dir CtrlPGrep call ctrlp#grep#run(<f-args>)
comm! -nargs=* -complete=dir CtrlPGrep call ctrlp#grep#run(<f-args>)

0 comments on commit 7bec8cb

Please sign in to comment.