As fugitive#statusline in the fugitive#statusline directory does not define as autoload , unfortunately, the use of the silent! call technique cannot be sniffed silent! call silent! call / exists (thanks @ Christopher). However, there are several alternatives:
- Put the triple branch in your
'statusline' option as suggested by @tungd. - Set
'statusline' in the after/plugin file, for example, as Christopher says. This solves the problem, but means that your status line is defined in a very unlikely place, so it is probably best to add a good comment to your ~/.vimrc file. - Just define the function in your
~/.vimrc file.
Example:
if !exists('*fugitive#statusline') function! fugitive
- Another option is to use the
Fugitive autocmd event, which defines Fugitive. Please note that this will only work when Fugitive detects the git directory.
Put something like this in your ~/.vimrc file:
augroup fugitive_status autocmd! autocmd user Fugitive set statusline=%<\ %f\ %{fugitive
Personally, I think @tungd's solution is the easiest. However, simply defining a dummy function will be my next choice. Fugitive will override it if Fugitive is installed. The best part is to keep the 'statusline' options neat and clean.
source share