preservim / tagbar

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

Asciidoc + Universal Ctags Not Working #786

Closed ossie-git closed 2 years ago

ossie-git commented 2 years ago

Hi,

I'm currently running the latest version of:

on Mac OS X with Vim 8.2

I've configured it to use Universal ctags by pointing it to the binary:

let g:tagbar_ctags_bin = '/opt/local/bin/uctags'

but whenever I run it on an Asciidoc document, Tagbar just shows nothing. I've verified that uctags successfully generates a local tags file when invoked from the CLI (I know Tagbar doesn't use this but I used it to verify that uctags works) and it is on the list of supported languages:

$ uctags --list-languages | grep -i asciidoc
Asciidoc

When I ran Tagbar in debugging mode, it finds uctags but then says that asciidoctor is an unsupported filetype, even though I verified that it is defined in uctags.vim:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Aug  1 2021 04:15:53)
macOS version - x86_64
Included patches: 1-2681
Compiled by MacPorts
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               +cindent           +cursorshape       +file_in_path      +ipv6              +lua               -mouse_sysmouse    -perl              -ruby              -tag_old_static    +toolbar           +wildmenu          
+arabic            +clientserver      +dialog_con_gui    +find_in_path      +job               +menu              +mouse_urxvt       +persistent_undo   +scrollbind        -tag_any_white     +transparency      +windows           
+autocmd           +clipboard         +diff              +float             +jumplist          +mksession         +mouse_xterm       +popupwin          +signs             -tcl               +user_commands     +writebackup       
+autochdir         +cmdline_compl     +digraphs          +folding           +keymap            +modify_fname      +multi_byte        +postscript        +smartindent       +termguicolors     +vartabs           -X11               
-autoservername    +cmdline_hist      +dnd               -footer            +lambda            +mouse             +multi_lang        +printer           -sound             +terminal          +vertsplit         -xfontset          
+balloon_eval      +cmdline_info      -ebcdic            +fork()            +langmap           +mouseshape        -mzscheme          +profile           +spell             +terminfo          +virtualedit       +xim               
+balloon_eval_term +comments          +emacs_tags        +fullscreen        +libcall           +mouse_dec         +netbeans_intg     -python            +startuptime       +termresponse      +visual            -xpm               
+browse            +conceal           +eval              +gettext           +linebreak         -mouse_gpm         +num64             +python3           +statusline        +textobjects       +visualextra       -xsmp              
++builtin_terms    +cryptv            +ex_extra          -hangul_input      +lispindent        -mouse_jsbterm     +odbeditor         +quickfix          -sun_workshop      +textprop          +viminfo           -xterm_clipboard   
+byte_offset       -cscope            +extra_search      +iconv             +listcmds          +mouse_netterm     +packages          +reltime           +syntax            +timers            +vreplace          -xterm_save        
+channel           +cursorbind        -farsi             +insert_expand     +localmap          +mouse_sgr         +path_extra        +rightleft         +tag_binary        +title             +wildignore        
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/opt/local/MacVim.app/Contents/Resources/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe -I/opt/local/include -DMACOS_X -DMACOS_X_DARWIN -pipe -Os -arch x86_64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: /usr/bin/clang -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -o Vim -lm -lncurses -liconv -lintl -framework AppKit -L/opt/local/lib -llua -L/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/config-3.9-darwin -lpython3.9 -framework CoreFoundation 2021-08-02 09:09:37.266753: ToggleWindow called
2021-08-02 09:09:37.267205: OpenWindow called with flags: ''
2021-08-02 09:09:37.268057: Checking for Exuberant Ctags
2021-08-02 09:09:37.268361: EscapeCtagsCmd called
2021-08-02 09:09:37.268522: ctags_bin: /opt/local/bin/uctags
2021-08-02 09:09:37.268681: ctags_args (is a string): --version
2021-08-02 09:09:37.269017: Escaped ctags command: '/opt/local/bin/uctags' --version
2021-08-02 09:09:37.269213: Executing ctags command: '/opt/local/bin/uctags' --version
2021-08-02 09:09:37.287883: Calling shell to execute: "('/opt/local/bin/uctags' --version)>/var/folders/4v/0pbx0h550_96zzlblwm3clbh0000gn/T/vU0Ptef/0 2>&1"
2021-08-02 09:09:37.288310: Exit code: 0
2021-08-02 09:09:37.293943: Command output:
Universal Ctags 5.9.0, Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Aug  1 2021, 04:32:48
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +xpath, +json, +interactive, +yaml, +case-insensitive-filenames, +packcc

2021-08-02 09:09:37.294209: Exit code: 0
2021-08-02 09:09:37.294506: Checking Exuberant Ctags version
2021-08-02 09:09:37.294658: Found Universal Ctags, assuming compatibility
2021-08-02 09:09:37.294857: Initializing types
2021-08-02 09:09:37.295014: Getting filetypes supported by Exuberant Ctags
2021-08-02 09:09:37.295213: EscapeCtagsCmd called
2021-08-02 09:09:37.295414: ctags_bin: /opt/local/bin/uctags
2021-08-02 09:09:37.295600: ctags_args (is a string): --list-languages
2021-08-02 09:09:37.295849: Escaped ctags command: '/opt/local/bin/uctags' --list-languages
2021-08-02 09:09:37.296003: Executing ctags command: '/opt/local/bin/uctags' --list-languages
2021-08-02 09:09:37.314705: Calling shell to execute: "('/opt/local/bin/uctags' --list-languages)>/var/folders/4v/0pbx0h550_96zzlblwm3clbh0000gn/T/vU0Ptef/1 2>&1"
2021-08-02 09:09:37.314950: Exit code: 0
2021-08-02 09:09:37.334612: Detected gotags, overriding typedef
2021-08-02 09:09:37.338849: Creating autocommands
2021-08-02 09:09:37.339411: AutoUpdate called [/private/tmp/ascii/1.adoc]
2021-08-02 09:09:37.339654: Vim filetype: 'asciidoctor', sanitized filetype: 'asciidoctor'
2021-08-02 09:09:37.339806: Checking if file is valid [/private/tmp/ascii/1.adoc]
2021-08-02 09:09:37.340017: Unsupported filetype: asciidoctor
2021-08-02 09:09:37.340145: Not a valid file, stopping processing
2021-08-02 09:09:37.365726: AutoUpdate called [/private/tmp/ascii/__Tagbar__.1]
2021-08-02 09:09:37.365967: Still opening window, stopping processing
2021-08-02 09:09:37.378746: InitWindow called with autoclose: 0
2021-08-02 09:09:37.397438: AutoUpdate called [/private/tmp/ascii/__Tagbar__.1]
2021-08-02 09:09:37.397714: In Tagbar window, stopping processing
2021-08-02 09:09:37.399087: Mapping keys
2021-08-02 09:09:37.400197: InitWindow finished
2021-08-02 09:09:37.400386: AutoUpdate called [/private/tmp/ascii/1.adoc]
2021-08-02 09:09:37.400581: Vim filetype: 'asciidoctor', sanitized filetype: 'asciidoctor'
2021-08-02 09:09:37.400721: Checking if file is valid [/private/tmp/ascii/1.adoc]
2021-08-02 09:09:37.400949: Unsupported filetype: asciidoctor
2021-08-02 09:09:37.401081: Not a valid file, stopping processing
2021-08-02 09:09:37.442149: AutoUpdate called [/private/tmp/ascii/1.adoc]
2021-08-02 09:09:37.442459: Vim filetype: 'asciidoctor', sanitized filetype: 'asciidoctor'
2021-08-02 09:09:37.442718: Checking if file is valid [/private/tmp/ascii/1.adoc]
2021-08-02 09:09:37.443030: Unsupported filetype: asciidoctor
2021-08-02 09:09:37.443184: Not a valid file, stopping processing
2021-08-02 09:09:37.443380: OpenWindow finished
2021-08-02 09:09:37.443564: ToggleWindow finished
2021-08-02 09:09:43.821608: CloseWindow called
2021-08-02 09:09:43.822122: goto_win(): 2wincmd w, 0
2021-08-02 09:09:43.843479: AutoUpdate called [/private/tmp/ascii/__Tagbar__.1]
2021-08-02 09:09:43.843796: In Tagbar window, stopping processing
2021-08-02 09:09:43.858272: AutoUpdate called [/private/tmp/ascii/1.adoc]
2021-08-02 09:09:43.858596: Vim filetype: 'asciidoctor', sanitized filetype: 'asciidoctor'
2021-08-02 09:09:43.858750: Checking if file is valid [/private/tmp/ascii/1.adoc]
2021-08-02 09:09:43.858963: Unsupported filetype: asciidoctor
2021-08-02 09:09:43.859086: Not a valid file, stopping processing
2021-08-02 09:09:43.859262: goto_win(): 1wincmd w, 0
2021-08-02 09:09:43.860165: CloseWindow finished

Even on a simple file such as this it shows nothing:

== Included Section

Look, I came from out of the [blue]#blue#!

--
I'm keepin' it open.

An 'open block', like this one, can contain other blocks.

It can also act as any other block. (TODO)
--

Any ideas? I've already looked at similar related issues but none of them solved my issue. Thanks.

alerque commented 2 years ago

The support in tagbar is for asciidoc, and your UCtags is reporting support for Asciidoc. Also the standard VIM filetype definition is asciidoc. Yet if you look at your log, the filetype it is looking for support for is asciidoctor (with the extra "tor" on the end). Where is your filetype being set to asciidoctor and why?

ossie-git commented 2 years ago

@alerque Nice catch. I'm using the vim-asciidoctor plugin which sets the filetype to asciidoctor. Is there a way to alias it or would I have to update uctags.vim?

alerque commented 2 years ago

You should be able to add support via your vim RC file as if you were adding a new filetype (see examples in the wiki) and then just set the value to the existing uctags config for asciidoc. That should effectively alias them.

We could also add this alias out of the box, but I'm a little hesitant to do that without understanding why that plugin is using a non standard filetype. That just smells wrong to me.

ossie-git commented 2 years ago

Got it working. Here's the section you add to your Vim RC in case anyone runs into this in the future:

let g:tagbar_type_asciidoctor = {
    \ 'ctagstype' : 'asciidoc',
    \ 'kinds'     : [
          \ 'c:chapter:0:1',
          \ 's:section:0:1',
          \ 'S:subsection:0:1',
          \ 't:subsubsection:0:1',
          \ 'T:paragraph:0:1',
          \ 'u:subparagraph:0:1',
          \ 'a:anchor:0:0',
    \ ],
    \ 'sro'        : '""',
    \ 'kind2scope' : {
          \ 'c' : 'chapter',
          \ 's' : 'section',
          \ 'S' : 'subsection',
          \ 't' : 'subsubsection',
          \ 'T' : 'l4subsection',
          \ 'u' : 'l5subsection',
    \ },
    \ 'scope2kind' : {
          \ 'chapter' : 'c',
          \ 'section' : 's',
          \ 'subsection' : 'S',
          \ 'subsubsection' : 't',
          \ 'l4subsection' : 'T',
          \ 'l5subsection' : 'u',
    \ },
    \ 'sort' : 0,
    \ }

Thank you for your help @alerque