4

I have the tagbar plugin working perfectly in vim but no tags are displayed in neovim.

When I use TagbarDebug from within both, I can see that the ctags output is fine when run from vim, but from neovim, tagbardebug.log.ctags_out just has the following line:

^[[31;01m'^[[39;00m^[[31;01m/usr/local/bin/ctags-f---format=2--excmd=pattern--fields=nksSaf--extra=--file-scope=yes--sort=no--append=no-V--language-force=python--python-kinds=icfmv/var/folders/_z/tz5sb8jd6mj41gj2gn8qvhhr0000gn/T/nvimoU8Oxr/1.py^[[39;00m^[[31;01m'^[[39;00m

From tagbardebug.log, I can see that ctags is called slightly differently between the two. From within vim, the log has:

Calling shell to execute: "('/usr/local/bin/ctags' '-f' '-' '--format=2' '--excmd=pattern' '--fields=nksSaf' '--extra=' '--file-scope=yes' '--sort=no' '--append=no' '-V' '--language-force=python' '--python-kinds=icfmv' '/var/folders/_z/tz5sb8jd6mj41gj2gn8qvhhr0000gn/T/v0jhgoR/4.py') >/var/folders/_z/tz5sb8jd6mj41gj2gn8qvhhr0000gn/T/v0jhgoR/5 2>&1"

but from neovim, the equivalent line is:

Executing command: "'/Users/owen/miniconda3/bin/xonsh' '-c' ''/usr/local/bin/ctags' '-f' '-' '--format=2' '--excmd=pattern' '--fields=nksSaf' '--extra=' '--file-scope=yes' '--sort=no' '--append=no' '-V' '--language-force=python' '--python-kinds=icfmv' '/var/folders/_z/tz5..."

The difference appears to be how ctags is being called - vim calls it directly but neovim calls the shell executable and passes the -c argument. However, if I run the command used by neovim from the command line, it works fine.

I've tried setting tagbar_ctags_bin, but that made no difference.

Any clues as to where else I need to dig?

meatballs
  • 3,917
  • 1
  • 15
  • 19
  • 1
    I suspect that vim is _also_ calling the shell, it's just that neovim is being explicit about it. vim says: "_calling shell_ to execute [blah blah blah]". neovim says: "Executing command [your weird shell] -c [blah blah blah]". Is it possible vim is calling via a different shell? How would we tell? – David Jones Apr 29 '19 at 09:31
  • I did wonder whether xonsh might be the issue, but it hadn't occurred to me that vim might be 'doing its own thing' I might try changing my default shell to bash and see what happens. – meatballs Apr 29 '19 at 09:37

1 Answers1

2

My guess is that xonsh makes some assumptions about being connected to a terminal, which is true in terminal Vim but not gVim nor Neovim (which invokes commands using pipes).

Try setting shell* options to their default values:

:set shell& shellcmdflag& shellpipe& shellquote& shellredir& shellxquote& shellxescape&

(Or simply remove the lines in your config that set those options.)

The difference appears to be how ctags is being called - vim calls it directly but neovim calls the shell executable and passes the -c argument

No, that's just a difference in log output. Vim also uses the 'shell' option and 'shellcmdflag' options (which is hinted by its log message: Calling shell to execute...).

Justin M. Keyes
  • 6,679
  • 3
  • 33
  • 60
  • Fantastic! That's the issue! Adding a line in init.vim to set the shell as bash has solved it. Thank you kindly – meatballs Apr 29 '19 at 09:58