git-time-metric / gtm-vim-plugin

Plugin for the Vim editor to be used with the Git Time Metric platform.
MIT License
59 stars 4 forks source link

Disable warning that executable `gtm` does not exist #5

Closed niklaas closed 5 years ago

niklaas commented 5 years ago

I use vim on more machines that I use gtm. So gtm isn't always installed. Is there some way to silent the annoying complaint that gtm cannot be found when vim is started?

mschenk42 commented 5 years ago

In you .vimrc you can check if the executable exists before loading the plugin.

I use vim-plug to manage my plugins.

if executable('gtm')
   Plug 'git-time-metric/gtm-vim-plugin'
endif
niklaas commented 5 years ago

Of course! I have this in my .vimrc anyway:

" Conditional activation for vim-plug plugins
" https://github.com/junegunn/vim-plug/wiki/tips#conditional-activation
function! Cond(cond, ...)
  let opts = get(a:000, 0, {})
  return a:cond ? opts : extend(opts, { 'on': [], 'for': [] })
endfunction

So it's as simple as

Plug 'git-time-metric/gtm-vim-plugin', Cond(executable('gtm'))

Could have come up with that myself. Thank you!