preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.11k stars 486 forks source link

Tagbar on Windows issuing wrong command #628

Open afonsolage opened 4 years ago

afonsolage commented 4 years ago

When I try to run :TagbarToggle I get the following error:

Tagbar: Ctags doesn't seem to be Exuberant Ctags!
BSD ctags will NOT WORK. Please [...]
Executed command: ""ctags" --version"
Command output:
ParserError:
Line |
   1 |  ""ctags" --version"
     |    ~~~~~~~~~~~~~~~~~
     | Unexpected token 'ctags" --version"' in expression or statement.
Exit code: 1

I'm using PowerShell Core and the command ""ctags" --version" won't work because the extra quotes. So this is my shell config on NeoVim:

set shell=pwsh
set shellquote= shellpipe=\| shellxquote=
set shellcmdflag=-NoLogo\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command
set shellredir=\|\ OutFile\ -Encoding\ UTF8

It seems that Tagbar is ignoring the shellquote and shellxquote configurations.

If I run ctags --version I got the following output:

Universal Ctags 0.0.0(79799bd4), Copyright (C) 2015 Universal Ctags Team                                                                                                                       
Universal Ctags is derived from Exuberant Ctags.                                                                                                                                               
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert                                                                                                                                    
  Compiled: Jul 10 2020, 00:08:01                                                                                                                                                              
  URL: https://ctags.io/                                                                                                                                                                       
  Optional compiled features: +win32, +wildcards, +regex, +internal-sort, +unix-path-separator, +iconv, +option-directory, +xpath, +json, +interactive, +yaml, +case-insensitive-filenames, +packcc                                                                                                                                                                                           

There is any workaround for this?

Thanks!

alerque commented 4 years ago

I don't think we have any support for pwsh yet. Windows is supported other ways, but not with the VIM shell changed like this.

I'd be happy to accept a contribution that fixed this for first class Powershell support and escaping everything right across platforms, but I don't have access to or experience with Windows to make this happen myself. If you'd like to take a stab at it go ahead. I think there are some other shell support functions you could model from.

avysk commented 1 year ago

I have very much the same problem.

My settings are

  set shell=pwsh\ -nop\ -nol
  set shellcmdflag=-c

Commenting these out makes TagBar to run.

avysk commented 1 year ago

I have managed to (probably) solve the problem, writing my own function, temporarily substituting cmd for shell:

function! MyTagbarToggle()
  if has("win32") " tagbar is broken with pwsh
    let l:old_shell=&shell
    set shell=cmd
  endif
  execute "TagbarToggle"
  if exists("l:old_shell")
    let &shell=l:old_shell
  endif
endfunction
alerque commented 1 year ago

@avysk Happy to facilitate PR's that will solve this for everybody if you want to contribute.