1

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 and global to make sure they are not executable
  • Run nvim from PowerShell

  • Using: 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 available

  • Close nvim and PowerShell

  • Add programs back to path
  • Open PowerShell
  • Test ctags and global to make sure they are executable

  • Using: 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 and nvim-qt

1 Answer 1

2

You can do it like this:

if executable('ctags') || executable('global')
    call dein#add('...')
endif
10
  • That's what I was doing when I was using Vundle. But I was under the impression that Dein could handle this for me. In this issue they use Dein to install fzf and then check for it before loading the fzf plugin. That's what I'm going for. Commented Jul 27, 2018 at 14:25
  • Why would you use a feature, that makes you depend on a plugin rather than using something which you can independently of any plugin? Commented Jul 29, 2018 at 10:06
  • I'm not sure I understand you. Are you asking why am I using external programs like ctags and global? Because they make my life easier. But I don't want to depend on them. I want my plugin manager to only load the plugin if the feature exists. Or are you asking why use a feature of Dein rather than basic vimscript? What's the point of using plugins at all if I'm not going to make use of their features? I'm depending on one plugin, my plugin manager, to manage my plugins and only load those that the underlying system supports. Commented Jul 30, 2018 at 18:35
  • No I am asking why would you depend on a solution specific to dein, when you can use the same thing with any plugin manager you might happen to use in the future? Commented Jul 31, 2018 at 9:05
  • Why use a plugin at all if you're not going to make use of its features? Dein is just vimscript that loads more vimscript. Why not write every command and function I need myself and not depend on anybody? We could wax philosophical all day about this. But the point is that Dein has many much more powerful and complex options but I cannot get this simple example to work reliably. I'm trying to figure out if it's my dot file, nvim/Win10/PS combo, or Dein that's the problem. Commented Jul 31, 2018 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.