I'd like fzf.vim GFiles to add my current directory to initial query.
Before:
After:
I end up to create a custom commandGFilesMonorepo
. Here is the implementation:
" ported from https://github.com/junegunn/fzf.vim/blob/master/autoload/fzf/vim.vim#L546function!s:get_git_root()letl:root=split(system('git rev-parse --show-toplevel'),'\n')[0]ifv:shell_errorreturn''endifreturnl:rootendfunctionfunction!s:gitfiles_monorepo()letl:root=s:get_git_root()letl:path=substitute(getcwd(),l:root,'','')letl:path=substitute(l:path,'/','','')letl:options='-m --preview "head -20 {1}" --prompt "GitFiles> " 'ifl:path!=''letl:options.='--query '.l:pathendifcall fzf#run({ \'source':'git ls-files | uniq', \'sink':'e', \'dir':l:root, \'options':l:options, \'down':'40%' \})endfunctioncommand! GFilesMonorepocalls:gitfiles_monorepo()
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse