Search code examples
vimneovimtagbar

Tagbar plugin works in vim but not neovim


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?


Solution

  • 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...).