mileszs / ack.vim

Vim plugin for the Perl module / CLI script 'ack'
Other
3.08k stars 396 forks source link

Support search string placeholder in ackprg, like vim-grepper #218

Open hanxi opened 7 years ago

hanxi commented 7 years ago

Just like this https://github.com/mhinz/vim-grepper/blob/master/autoload/grepper.vim#L642

In cases where the arguments don't come last, use $ as a placeholder: `'grepprg': 'grep -Rn $ .'`

Because I want use set search path in ack.vim for my project like this in grepper:

function! FindProjectRoot(lookFor)
    let pathMaker='%:p'
    while(len(expand(pathMaker))>len(expand(pathMaker.':h')))
        let pathMaker=pathMaker.':h'
        let fileToCheck=expand(pathMaker).'/'.a:lookFor
        if filereadable(fileToCheck)||isdirectory(fileToCheck)
            return expand(pathMaker)
        endif
    endwhile
    return expand('%:p:h')
endfunction
nmap gs  <plug>(GrepperOperator)
xmap gs  <plug>(GrepperOperator)
let g:grepper = {}
let g:grepper.ag = {}
let g:grepper.ag.grepprg = 'ag --vimgrep $* '.FindProjectRoot('.project')
ches commented 6 years ago

Hi, sorry for the slow response—this is not currently supported, but it's a nice feature, I'd accept it as a contribution.