Search code examples
vimgoack

How to include .go for search for Ack in VIM?


Here is my .vimrc for Ack, But it can't search .go files, I'd like add .go support.

let g:ackprg="ack-grep -H --nocolor --nogroup --column"

function! Ack(args)

let grepprg_bak=&grepprg
exec "set grepprg=" . g:ackprg
execute "silent! grep " . a:args
botright copen
let &grepprg=grepprg_bak
exec "redraw!"

endfunction

command! -nargs=* -complete=file Ack call Ack(<q-args>)

Solution

  • Since version 1.94, ack has support for the Go language built-in.

    $ ack --help type
    ...
        --[no]go           .go
    

    You can explicitly enable it by passing --go, but it should be included in the search by default.