Fzf: [feature-request] Vim plugin should provide option to search through all files in current project dir

Created on 6 Oct 2015  ยท  3Comments  ยท  Source: junegunn/fzf

As in #368, this is a clone of a feature existing in CtrlP. Imagine I'm working on a project with this structure:

โ”œโ”€โ”€ .git
โ”œโ”€โ”€ module1
โ”‚ย ย  โ”œโ”€โ”€ bang
โ”œโ”€โ”€ module2
โ”‚ย ย  โ”œโ”€โ”€ boom
โ””โ”€โ”€ module3
ย ย  โ””โ”€โ”€ twang

If I am editing module3/twang, and I use FZF, I cannot see any files outside of module3/. CtrlP will traverse up the directory tree until it finds a .git, .svn, .hv, etc. folder. This means that any project that is under version control can easily be traversed using only this one navigation tool. Would it be possible to add something similar to FZF? If not in the standard options, perhaps with some additional configuration by the users?

question tip

Most helpful comment

Something like this?

function! s:find_root()
  for vcs in ['.git', '.svn', '.hg']
    let dir = finddir(vcs.'/..', ';')
    if !empty(dir)
      execute 'FZF' dir
      return
    endif
  endfor
  FZF
endfunction

command! FZFR call s:find_root()
  • FZF -> Files if you have fzf.vim project
  • Using VCS-specific commands to find the root should give more accurate results

    • e.g. git rev-parse --show-toplevel

  • You can consider using the low-level fzf#run() directly if you need more control

All 3 comments

Are you using autochdir? If so I suggest not doing that, it's a legacy option that should not be used.

Something like this?

function! s:find_root()
  for vcs in ['.git', '.svn', '.hg']
    let dir = finddir(vcs.'/..', ';')
    if !empty(dir)
      execute 'FZF' dir
      return
    endif
  endfor
  FZF
endfunction

command! FZFR call s:find_root()
  • FZF -> Files if you have fzf.vim project
  • Using VCS-specific commands to find the root should give more accurate results

    • e.g. git rev-parse --show-toplevel

  • You can consider using the low-level fzf#run() directly if you need more control

Thanks guys.

Closed #369

On Wed, Oct 7, 2015 at 3:40 AM Junegunn Choi [email protected]
wrote:

Something like this?

function! s:find_root()
for vcs in ['.git', '.svn', '.hg']
let dir = finddir(vcs.'/..', ';')
if !empty(dir)
execute 'FZF' dir
return
endif
endfor
FZFendfunction
command! FZFR call s:find_root()

  • FZF -> Files if you have fzf.vim project
  • Using VCS-specific commands to find the root should give more
    accurate results

    • e.g. git rev-parse --show-toplevel

  • You can consider using the low-level fzf#run() directly if you need
    more control

โ€”
Reply to this email directly or view it on GitHub
https://github.com/junegunn/fzf/issues/369#issuecomment-146053423.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  ยท  3Comments

lbeier picture lbeier  ยท  3Comments

fenuks picture fenuks  ยท  3Comments

jan-warchol picture jan-warchol  ยท  3Comments

firedev picture firedev  ยท  3Comments