fzf.vim icon indicating copy to clipboard operation
fzf.vim copied to clipboard

GFiles from non git root?

Open korken89 opened this issue 2 years ago • 3 comments

  • [x] I have fzf 0.23.0 or above
  • [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
  • [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
  • [x] I have read through the manual page of fzf (man fzf)
  • [x] I have searched through the existing issues

Hi, I have been looking at configuring the GFiles command. The issues I am having is that the command assumes that it should run the git ls-files command from the root of the repository, instead from where vim was opened. This turns out great when you have a single git repository, but e.g. when I work we have large repos with with projects within the same git repository. In this usecase I'd like to have git ls-files in GFiles run from where I opened vim, not the root of the project.

Is there anyway to achieve this? Thanks for the assistance!

korken89 avatar Sep 19 '21 05:09 korken89

Looking at the source code: https://github.com/junegunn/fzf.vim/blob/bd703a7a7d7afd113634a346290acc27dd314bfc/autoload/fzf/vim.vim#L621-L628 I think it was hardcoded, so it's kind of tricky to configure. And using :GFiles . doesn't seem to do anything.

The best I could suggest is making a new function with fzf#wrap() and then make a new command with it. You can take a look at fzf#vim#gitfiles() in autoload/fzf/vim.vim for reference.

bruhtus avatar Sep 20 '21 10:09 bruhtus

Thanks for the tip, I'll give it a try and report back!

korken89 avatar Sep 20 '21 12:09 korken89

I just realized that there's a PR for it. You can take a look here: https://github.com/junegunn/fzf.vim/pull/1290, and see if it works or not.

bruhtus avatar Sep 21 '21 05:09 bruhtus