Fzf: FZF and Ag in vim doesn't honor gitignore

Created on 23 Aug 2015  路  4Comments  路  Source: junegunn/fzf

Using Ag it's self or ag with ctrl-p, I'm able to ignore the directories that are listed in my .gitignore. This is infact default for Ag, but for some reason, FZF with ag isn't doing the same.

https://github.com/mhartington/dotfiles/blob/master/nvimrc#L368

  function! s:ag_handler(lines)
    if len(a:lines) < 2 | return | endif

    let cmd = get({'ctrl-x': 'split',
                \ 'ctrl-v': 'vertical split',
                \ 'ctrl-t': 'tabe'}, a:lines[0], 'e')
    let list = map(a:lines[1:], 's:ag_to_qf(v:val)')

    let first = list[0]
    execute cmd escape(first.filename, ' %#\')
    execute first.lnum
    execute 'normal!' first.col.'|zz'

    if len(list) > 1
      call setqflist(list)
      copen
      wincmd p
    endif
  endfunction
  command! -nargs=* Ag call fzf#run({
  \ 'source':  printf('ag --nogroup --column --nocolor "%s"',
  \                   escape(empty(<q-args>) ? '^(?=.)' : <q-args>, '"\')),
  \ 'sink*':    function('<sid>ag_handler'),
  \ 'options': '--ansi --expect=ctrl-t,ctrl-v,ctrl-x --delimiter : --nth 4.. '.
  \            '--multi --bind ctrl-a:select-all,ctrl-d:deselect-all ',
  \ 'down':    '35%'
  \ }) "}}}
"}}}
"

Any idea whats up?
By the way, love the plugin, so fast!

invalid question

All 4 comments

Does ag --nogroup --column --nocolor QUERY give you the expected result? Then I don't see how your Ag command can go wrong.

FYI, you might also want to check out fzf.vim repository that I recently started working on; https://github.com/junegunn/fzf.vim

Hmm, I thought I had copied that down, but it appears to work when I use your plugin. Thanks a lot!

One last question if you don't mind, is there any way to make the default :FZF function respect your git ignore as well?

It looks like you misunderstood the Ag example. The Ag command you copied from the wiki is not just for listing files, but for searching for the given text in the files a la grep. And having the above Ag command in your .vimrc obviously does not affect :FZF command.

The answer to your question is on the README page. See https://github.com/junegunn/fzf#respecting-gitignore-hgignore-and-svnignore

Ahh alright, I wasn't aware that the shell command and options would also be used in vim. Thanks for pointing that out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisamow picture chrisamow  路  3Comments

jan-warchol picture jan-warchol  路  3Comments

firedev picture firedev  路  3Comments

lbeier picture lbeier  路  3Comments

olethanh picture olethanh  路  3Comments