You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have specified let $FZF_DEFAULT_COMMAND = 'ag -g ""' in vim and in .zshrc i have export FZF_DEFAULT_COMMAND='ag --hidden --ignore dist node_modules .git -g ""'
but still getting an output with files from dist folder
the dist folder is in .gitignore
# build
**/dist
**/build
**/dist-zip
Mac M2 macvim
fzf --version
0.57.0 (0476a65)
at the end if it will be ignored , how can i make it include if i need ?
the only way (from here mileszs/ack.vim#210 (comment)) i have made it work is to add .ignore file in my project with
function! SearchVisualSelectionWithAg() range
let old_reg = getreg('"')
let old_regtype = getregtype('"')
let old_clipboard = &clipboard
set clipboard&
normal! ""gvy
let selection = getreg('"')
call setreg('"', old_reg, old_regtype)
let &clipboard = old_clipboard
execute 'Ag' selection
endfunction
function! SearchWithAgInDirectory(...)
call fzf#vim#ag(join(a:000[1:], ' '), extend({'dir': a:1}, g:fzf#vim#default_layout))
endfunction
command! -nargs=+ -complete=dir AgIn call SearchWithAgInDirectory()
" }}}
nnoremap f :FZF -q =expand("")
function! s:getVisualSelection()
let [line_start, column_start] = getpos("'<")[1:2]
let [line_end, column_end] = getpos("'>")[1:2]
let lines = getline(line_start, line_end)
if len(lines) == 0
return ""
endif
let lines[-1] = lines[-1][:column_end - (&selection == "inclusive" ? 1 : 2)]
let lines[0] = lines[0][column_start - 1:]
return join(lines, "\n")
endfunction
vnoremap f :FZF -q =getVisualSelection()
let g:fzf_history_dir = '~/.local/share/fzf-history'
let $FZF_DEFAULT_COMMAND = 'ag --ignore dist -g ""'
" Open files in horizontal split
nnoremap s :call fzf#run({
\ 'down': '40%',
\ 'sink': 'botright split' })
" Open files in vertical horizontal split
nnoremap v :call fzf#run({
\ 'right': winwidth('.') / 2,
\ 'sink': 'vertical botright split' })
</details>
The text was updated successfully, but these errors were encountered:
rihannarickeminem
changed the title
How to make fzf with Ag not display files and folders from .gitignore?
How to make fzf with Ag not display files and folders from .gitignore in vim?
Jan 9, 2025
If I'm not mistaken, --ignore only takes a single argument, so the command is invalid.
cd /tmp
mkdir foo
cd foo
ag --hidden --ignore dist node_modules .git -g ""
gives errors
ERR: Error stat()ing: node_modules
ERR: Error opening directory node_modules: No such file or directory
ERR: Error stat()ing: .git
ERR: Error opening directory .git: No such file or directory
Anyway, having let $FZF_DEFAULT_COMMAND = 'ag --ignore dist -g ""' alone in .vimrc makes :FZF "gitignore" files as expected.
To make sure that :FZF is picking up the variable, I even tried changing it to
let$FZF_DEFAULT_COMMAND='seq 100; ag --ignore dist -g ""; seq 100'
and yes, :FZF does use it and shows numbers around the list.
Checklist
man fzf
)Output of
fzf --version
0.57.0 (0476a65)
OS
Shell
Problem / Steps to reproduce
I have specified
let $FZF_DEFAULT_COMMAND = 'ag -g ""'
in vim and in .zshrc i haveexport FZF_DEFAULT_COMMAND='ag --hidden --ignore dist node_modules .git -g ""'
but still getting an output with files from
dist
folderthe
dist
folder is in .gitignoreMac M2
macvim
at the end if it will be ignored , how can i make it include if i need ?
the only way (from here mileszs/ack.vim#210 (comment)) i have made it work is to add .ignore file in my project with
but how to make it work for all projects
this solution does not work junegunn/fzf.vim#453 (comment)
Here is parts for fzf in my config
let g:go_imports_autosave = 0
Plug 'drmikehenry/vim-fontsize'
nmap = FontsizeBegin
nmap + FontsizeInc
nmap - FontsizeDec
nmap 0 FontsizeDefault
" {{{
let g:fzf_nvim_statusline = 0 " disable statusline overwriting
" nnoremap :GFiles
nnoremap :Files
nnoremap a :Buffers
nnoremap A :Windows
nnoremap ; :BLines
nnoremap o :BTags
nnoremap O :Tags
nnoremap ? :History
nnoremap / :execute 'Ag ' . input('Ag/')
nnoremap . :AgIn
nnoremap K :call SearchWordWithAg()
vnoremap K :call SearchVisualSelectionWithAg()
nnoremap gl :Commits
nnoremap ga :BCommits
nnoremap ft :Filetypes
" https://vi.stackexchange.com/questions/31012/what-does-plug-do-in-vim
imap (fzf-complete-file-ag)
imap (fzf-complete-line)
imap (fzf-complete-word)
function! SearchWordWithAg()
execute 'Ag' expand('')
endfunction
function! SearchVisualSelectionWithAg() range
let old_reg = getreg('"')
let old_regtype = getregtype('"')
let old_clipboard = &clipboard
set clipboard&
normal! ""gvy
let selection = getreg('"')
call setreg('"', old_reg, old_regtype)
let &clipboard = old_clipboard
execute 'Ag' selection
endfunction
function! SearchWithAgInDirectory(...)
call fzf#vim#ag(join(a:000[1:], ' '), extend({'dir': a:1}, g:fzf#vim#default_layout))
endfunction
command! -nargs=+ -complete=dir AgIn call SearchWithAgInDirectory()
" }}}
nnoremap f :FZF -q =expand("")
function! s:getVisualSelection()
let [line_start, column_start] = getpos("'<")[1:2]
let [line_end, column_end] = getpos("'>")[1:2]
let lines = getline(line_start, line_end)
endfunction
vnoremap f :FZF -q =getVisualSelection()
let g:fzf_history_dir = '~/.local/share/fzf-history'
let $FZF_DEFAULT_COMMAND = 'ag --ignore dist -g ""'
" Open files in horizontal split
nnoremap s :call fzf#run({
\ 'down': '40%',
\ 'sink': 'botright split' })
" Open files in vertical horizontal split
nnoremap v :call fzf#run({
\ 'right': winwidth('.') / 2,
\ 'sink': 'vertical botright split' })
The text was updated successfully, but these errors were encountered: