Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make fzf with Ag not display files and folders from .gitignore in vim? #4168

Open
5 of 10 tasks
rihannarickeminem opened this issue Jan 9, 2025 · 0 comments
Open
5 of 10 tasks

Comments

@rihannarickeminem
Copy link

rihannarickeminem commented Jan 9, 2025

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.57.0 (0476a65)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

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

dist

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

```Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim'

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)

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> 

@rihannarickeminem 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant