If in folder, use gitignore in Ag command.

This commit is contained in:
empathicqubit 2018-12-13 11:38:21 -08:00
parent 351af16cad
commit 9d8521bc63

View file

@ -1,7 +1,7 @@
" Copyright (c) 2017 Junegunn Choi " Copyright (c) 2017 Junegunn Choi
" "
" MIT License " MIT License
"
" Permission is hereby granted, free of charge, to any person obtaining " Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the " a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including " "Software"), to deal in the Software without restriction, including
@ -508,13 +508,7 @@ function! s:get_git_root()
return v:shell_error ? '' : root return v:shell_error ? '' : root
endfunction endfunction
function! fzf#vim#gitfiles(args, ...) function! fzf#vim#gitsources(args, ...)
let root = s:get_git_root()
if empty(root)
return s:warn('Not in git repo')
endif
let paths = '' let paths = ''
for nr in range(1, bufnr('$')) for nr in range(1, bufnr('$'))
let path = expand('#' . nr . ':p') let path = expand('#' . nr . ':p')
@ -537,9 +531,18 @@ function! fzf#vim#gitfiles(args, ...)
let exclude_current = " | grep -x -v '" . paths . "'" let exclude_current = " | grep -x -v '" . paths . "'"
endif endif
return '{ git grep --cached -Il "" && git ls-files --others --exclude-standard ; } ' . a:args . exclude_current . (s:is_win ? '' : ' | uniq')
endfunction
function! fzf#vim#gitfiles(args, ...)
let root = s:get_git_root()
if empty(root)
return s:warn('Not in git repo')
endif
if a:args != '?' if a:args != '?'
return s:fzf('gfiles', { return s:fzf('gfiles', {
\ 'source': '{ git grep --cached -Il "" && git ls-files --others --exclude-standard ; } ' . a:args . exclude_current . (s:is_win ? '' : ' | uniq'), \ 'source': fzf#vim#gitsources(a:args),
\ 'dir': root, \ 'dir': root,
\ 'options': '-m --prompt "GitFiles> "' \ 'options': '-m --prompt "GitFiles> "'
\}, a:000) \}, a:000)
@ -695,7 +698,14 @@ function! fzf#vim#ag_raw(command_suffix, ...)
if !executable('ag') if !executable('ag')
return s:warn('ag is not found') return s:warn('ag is not found')
endif endif
return call('fzf#vim#grep', extend(['ag --nogroup --column --color '.a:command_suffix, 1], a:000))
let root = s:get_git_root()
let useignore=''
if !empty(root)
let useignore=' -U -p '.root.'/.gitignore'
endif
return call('fzf#vim#grep', extend(['ag'.useignore.' --nogroup --column --color '.a:command_suffix, 1], a:000))
endfunction endfunction
" command, with_column, [options] " command, with_column, [options]