From 7721fb2677e601943c9d6872ae36380cac66b78c Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 9 Nov 2016 18:51:55 +0900 Subject: [PATCH] Check if fugitive#repo() exists Caused by #239. Close #241. --- autoload/fzf/vim.vim | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 12e32c9..2224073 100644 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -405,12 +405,14 @@ endfunction " helper function to get the git root. Uses vim-fugitive if available for EXTRA SPEED! function! s:get_git_root() - try - return fugitive#repo().tree() - catch - let root = split(system('git rev-parse --show-toplevel'), '\n')[0] - return v:shell_error ? '' : root - endtry + if exists('*fugitive#repo') + try + return fugitive#repo().tree() + catch + endtry + endif + let root = split(system('git rev-parse --show-toplevel'), '\n')[0] + return v:shell_error ? '' : root endfunction function! fzf#vim#gitfiles(args, ...)