I'm trying to set up Dein to load the gen_tags plugin. However, if Universal/Exuberant Ctags or GNU Global aren't found on the path, I get the following error message when trying to start nvim
:
ctags not found
gen_tags.vim need ctags to generate tags
GNU Global not found
gen_gtags.vim need GNU Global
Press ENTER or type command to continue
Pressing enter does nothing. Sometimes I can get the prompt back with CtrlC. Sometimes it locks up and I have to crash the shell. I haven't found what controls that behavior yet. If ctags
and global
are on the $PATH
, everything works great.
But ideally I would like Dein to only attempt to load the plugin if ctags
or global
are available so I don't encounter this error message when setting up a new machine.
Here are three different options that I've tried:
call dein#add('jsfaint/gen_tags.vim', { 'depends': ['ctags', 'global']}) "tag maintainer
call dein#add('jsfaint/gen_tags.vim', { 'on_cmd': ['ctags', 'global']}) "tag maintainer
call dein#add('jsfaint/gen_tags.vim', { 'on_if': 'empty(glob($VIM."/exe/ctags"))'}) "tag maintainer
What are the correct options to pass to Dein to conditionally load this plugin?
I'm doing this on Windows 10 and PowerShell with neovim. I haven't tried this on a Linux system yet but eventually I would like this to work cross platform.
I've tried Christian's solution as well as another Dein option. Both fail to load the plugin when it is first added to the path and only nvim
is run. Launching nvim-qt
will load the plugin and both will load the plugin on subsequent launches. Occasionally (but not reliably) using the Dein option will cause the error noted above when the programs are not in the path.
*NOTE: when I say "Open" or "Close" below, I mean all associated windows. There are 3 or 4 windows to go through to change the path and leaving some open or leaving PowerShell open seems to change the behavior.
To reproduce:
- Remove programs from path
- Close all path related windows
- Open PowerShell
- Test
ctags
andglobal
to make sure they are not executable Run
nvim
from PowerShellUsing:
if executable('ctags') || executable('global')
- No error
Using dein options:
{ 'if': 'executable("ctags") || executable("global")' })
- Sometimes causes an error that requires CtrlC to get back to prompt
- Sometimes no error
If no error, test that
:GenCtags
and:GenGTAGS
are not availableClose
nvim
andPowerShell
- Add programs back to path
- Open PowerShell
Test
ctags
andglobal
to make sure they are executableUsing:
if executable('ctags') || executable('global')
:GenCtags
and:GenGTAGS
are not available
Using dein options:
{ 'if': 'executable("ctags") || executable("global")' })
:GenCtags
and:GenGTAGS
are not available
Close
nvim
and PowerShell- These can be closed and reopened many times with the same result
Open
nvim-qt
using Cortana- Test that
:GenCtags
and:GenGTAGS
are available - Plugin will be loaded from now on in both
nvim
andnvim-qt