Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lucerion committed Jun 28, 2016
0 parents commit 37462db
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
36 changes: 36 additions & 0 deletions autoload/ctrlp/grep.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
" ==============================================================
" Description: CtrlP grep extension
" Author: Alexander Skachko <alexander.skachko@gmail.com>
" Homepage: https://github.com/lucerion/ctrlp-grep
" Version: 1.0
" Licence: BSD-3-Clause
" ==============================================================

if (exists('g:loaded_ctrlp_grep') && g:loaded_ctrlp_grep) ||
\ (v:version < 700) || &compatible
finish
endif

call add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#grep#init()',
\ 'accept': 'ctrlp#acceptfile',
\ 'lname': 'grep',
\ 'sname': 'grep',
\ '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)
call ctrlp#init(ctrlp#grep#id())
endfunc

func! ctrlp#grep#init()
return split(s:result, "\n")
endfunc

func! ctrlp#grep#id()
return g:ctrlp_builtins + len(g:ctrlp_ext_vars)
endfunc

let g:loaded_ctrlp_grep = 1
13 changes: 13 additions & 0 deletions plugin/ctrlp-grep.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
" ==============================================================
" Description: CtrlP grep extension
" Author: Alexander Skachko <alexander.skachko@gmail.com>
" Homepage: https://github.com/lucerion/ctrlp-grep
" Version: 1.0
" 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>)

0 comments on commit 37462db

Please sign in to comment.