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

Problem with latex beamer frames #593

Open jagjordi opened 4 years ago

jagjordi commented 4 years ago

Recently a new subparser for latex beamer classes has been added to universal ctags (https://github.com/universal-ctags/ctags/commit/942142fa061815f32dc4babe3d8116bf8400eb4f). Unfortunately tagbar doesn't seem to make use of the new tags that are created.

I have checked the tags file and it works fine when you call ctags main.tex but the sidebar in tagbar only shows the sections and subsections but ignores the frame titles and subtitles (kinds f and g). Here is an extract of my .vimrc which shows the configuration for tagbar

let g:tagbar_ctags_bin='C:/Program Files/ctags/ctags.exe'

let g:tagbar_type_tex = {
    \ 'kinds' : [
        \ 'i:includes:1:0',
        \ 'p:parts',
        \ 'c:chapters',
        \ 's:sections',
        \ 'u:subsections',
        \ 'b:subsubsections',
        \ 'f:frames',
        \ 'g:subframe',
        \ 'P:paragraphs:0:0',
        \ 'G:subparagraphs:0:0',
        \ 'l:labels:0:0',
        \ '?:unknown',
    \ ],
\ }

Am I doing something wrong? How can I get it to work with beamer class?

jagjordi commented 4 years ago

Could someone provide some tips on how to proceed with this? I have tried modifiying the ctags definitions (see jagjordi/tagbar@a3acc57fabdd63952cddec74432fea383c53f20c ) but it still doesnt work. How can I test if the internal tags file that tagbar generates is correct?

jagjordi commented 4 years ago

Can I get some pointers on how to test/debug this problem? I am trying to fix it and have a PR. @alerque

jagjordi commented 4 years ago

I found that removing line 1306 in tagbar.vim solves my issue. Not sure if that line is relevant for the rest of functionalities of the pluggin.

alerque commented 4 years ago

I'm sorry, I haven't had time to dig into this since I don't use beamer, but your latest comment is a clue.

I assume you are talking about autoload/tagbar.vim (there are three files with that name in this plugin but that's the only one with enough lines to have a 1306). That line has to to with supporting exuberant versions of ctags. I suspect you have a path issues and the ctags that vim is running is not the one you think it is running. You might try manually setting the full path to the binary you want it to run. It is detecting an exhuberant-ctags install somehow. See the pinned issue in this tracker for a little more on that topic.

jagjordi commented 4 years ago

I have the path configured as the pinned issue shows. I think that the problem is that universal ctags is not reporting the correct tags when the argument --extras= is used.

What I changed is this

        if s:ctags_is_uctags
            """ I removed this"""let ctags_args += [ '--extras=' ]
        else
            let ctags_args += [ '--extra=' ]
        endif

I am unsure what the purpose of having that flag with empty parameters is

alerque commented 4 years ago

What version of ctags are you actually running?

The fag is not empty, it gets appended in the following code.

jagjordi commented 4 years ago

This is my version

λ ctags --version
Universal Ctags 0.0.0(39e72505), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Feb 26 2020, 00:08:09
  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
RiMillo commented 4 years ago

Hi guys. Thanks for these tips. I agree with @jagjordi: tagbar finds the [sub]frame tags only if that line is skipped. One can compare two tagbardebug.log, with or without the line, and look at the number of tags found.

Now in my tagbar I have a special zone (scope, if you want) for the frames. That is ok, but I'd like my frame labels to be "children" of the section ones. I mean that are grouped under a section, for instance like the subsection labels are. Like this:

Section 1
  |_ Frame 1
  |_ Frame 2
Section 2
  |_ Frame 3
  |_ etc

I tried playing around with the folding associated to the frames but I didn't manage. How can I achieve this?