[enhancement] GFiles and Monorepo
- Dominant language
- Vim Script
- Stars
- 10.3k
- Forks
- 608
- Avg merge
- 5d 8h
- Merged PRs (30d)
- 2
Description
- [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
First, thank you for the amazing library. I cannot do my job without fzf.vim.
Recently I'm working monorepo projects and found a way to filter target files based on the current working directory. I've wrote a custom function, `GFilesMonorepo`, which include the current working directory to `GFiles` initial query.
# Code
Here is the implementation (draft):
```vim
" ported from https://github.com/junegunn/fzf.vim/blob/master/autoload/fzf/vim.vim#L546
function! s:get_git_root()
let l:root = split(system('git rev-parse --show-toplevel'), '\n')[0]
if v:shell_error
return ''
endif
return l:root
endfunction
function! s:gitfiles_monorepo()
let l:root = s:get_git_root()
let l:path = substitute(getcwd(), l:root, '', '')
let l:path = substitute(l:path, '/', '', '')
let l:options = '-m --no-unicode --preview "head -20 {1}" --prompt "GitFiles> " '
if l:path != ''
let l:options .= '--query '.l:path
endif
call fzf#run({
\ 'source': 'git ls-files | uniq',
\ 'sink': 'e',
\ 'dir': l:root,
\ 'options': l:options,
\ 'down': '40%'
\})
endfunction
command! GFilesMonorepo call s:gitfiles_monorepo()
```
# Example
e.g.) Running `GFiles` and `GFilesMonorepo` in `~/.config` directory, assuming `~/` is the git root directory.
### `GFiles`

### `GFilesMonorepo`

The question is, can I submit a PR to include this feature as a built-in command?
# appendix
since monorepo are getting popular, I think more people will need this feature.

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.