Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on configuration of g:tagbar_type_bib #856

Closed
andregpss opened this issue Aug 10, 2023 · 22 comments · Fixed by #857, #861 or #862
Closed

Error on configuration of g:tagbar_type_bib #856

andregpss opened this issue Aug 10, 2023 · 22 comments · Fixed by #857, #861 or #862

Comments

@andregpss
Copy link

I think there is an error on the suggested configuration for Bibtex files on the Wiki page.

The ctagstype variable must be set to bibtex, instead of bib. When i use bib, it does not work.

By the way, Misc references are not shown on Tagbar, although other types of references (Article, Books, etc) work.

@raven42
Copy link
Collaborator

raven42 commented Aug 11, 2023

It looks like the Wiki page entry is for a custom defined version for bibtex with a custom regex parser for bibtex files. Do you if universal-ctags has native support for bibtex now? Or do we still need to have the regex pattern definition?

Another part of this might be that we have to let vim know the correct file type. If vim has been updated since that wiki entry to know about bibtex files, then that could be the cause too. I.E. in a previous version vim may have just recognized the file extension and used that as the filetype, but now it may know the language and correctly label the filetype as bibtex.

Either way, ya it looks like the wiki page is out of date. If you can provide me with a sample bibtex file I can do some testing and look at updating it.

@andregpss
Copy link
Author

andregpss commented Aug 12, 2023

Thanks for answering.

Do you if universal-ctags has native support for bibtex now? Or do we still need to have the regex pattern definition?

Universal-ctags has native support for bibtex (ctags.exe --list-languages).
When I type ctags.exe references.bib on prompt, a tags file is created, containing tags for the references, including misc reference type.

If vim has been updated since that wiki entry to know about bibtex files, then that could be the cause too.

I'm using NeoVim 0.9.1. There may be a difference between using Vim and NeoVim.

If you can provide me with a sample bibtex file I can do some testing and look at updating it.

Here's a sample of reference.bib Bibtex file:

@inproceedings{emmerich2000software,
title={Software engineering and middleware: a roadmap},
author={Emmerich, Wolfgang},
booktitle={Proceedings of the Conference on The future of Software engineering},
pages={117--129},
year={2000},
organization={ACM}
}

@misc{schmidt1996pattern,
title={Pattern-Oriented Software Architecture, Volume 1: A System of Patterns},
author={Schmidt, D and Stal, M and Rohnert, H and Buschmann, F},
year={1996},
publisher={John Wiley & Sons}
}

@inproceedings{trilla2015improving,
title={Improving implicit parallelism},
author={Trilla, Jos{'e} Manuel Calder{'o}n and Runciman, Colin},
booktitle={Proceedings of the 8th ACM SIGPLAN Symposium on Haskell},
pages={153--164},
year={2015},
organization={ACM}
}

@inproceedings{marlow2009runtime,
title={Runtime support for multicore Haskell},
author={Marlow, Simon and Peyton Jones, Simon and Singh, Satnam},
booktitle={ACM Sigplan Notices},
volume={44},
number={9},
pages={65--78},
year={2009},
organization={ACM}
}
@inproceedings{hickey2008clojure,
title={The clojure programming language},
author={Hickey, Rich},
booktitle={Proceedings of the 2008 symposium on Dynamic languages},
pages={1},
year={2008},
organization={ACM}
}
@book{jones2003haskell,
title={Haskell 98 language and libraries: the revised report},
author={Jones, Simon Peyton},
year={2003},
publisher={Cambridge University Press}
}

@online{currying,
author = {HaskellWiki},
title = {Currying},
year = {2006},
url = {https://wiki.haskell.org/Currying},
urldate = {2016-02-29},
note = {Disponível em \url{https://wiki.haskell.org/Currying}. },
howpublished = {Acesso em 2016-02-29.}
}

@misc{merrick2006xml,
title={XML remote procedure call (XML-RPC)},
author={Merrick, Phillip and Allen, Stewart and Lapp, Joseph},
year={2006},
month=apr # "~11",
publisher={Google Patents},
note={US Patent 7,028,312}
}
@misc{morley2014json,
title={JSON-RPC 2.0 Specification},
author={Morley, Matt},
year={2014},
publisher={JSON-RPC}
}

@book{vanbrabant2008google,
title={Google Guice: agile lightweight dependency injection framework},
author={Vanbrabant, Robbie},
year={2008},
publisher={Apress}
}

@Article{appeltauer2011contextj,
title={ContextJ: Context-oriented programming with Java},
author={Appeltauer, Malte and Hirschfeld, Robert and Haupt, Michael and Masuhara, Hidehiko},
journal={Information and Media Technologies},
volume={6},
number={2},
pages={399--419},
year={2011},
publisher={Information and Media Technologies Editorial Board}
}

@book{siriwardena2013enterprise,
title={Enterprise Integration with Wso2 Esb},
author={Siriwardena, Prabath},
year={2013},
publisher={Packt Publishing Ltd}
}

@raven42
Copy link
Collaborator

raven42 commented Aug 14, 2023

@andregpss I've created a PR that adds native bibtex support. Can you help me identify which ones need the fold and stl (scope) fields set? Currently the PR has all kinds marked with a 0 for both, but that probably isn't accurate.

@andregpss
Copy link
Author

andregpss commented Aug 14, 2023

@andregpss I've created a PR that adds native bibtex support. Can you help me identify which ones need the fold and stl (scope) fields set? Currently the PR has all kinds marked with a 0 for both, but that probably isn't accurate.

My opinion is that all kinds should be marked with 1 for both. Something like:

let g:tagbar_type_bib = {
    \ 'ctagstype' : 'bib',
    \ 'kinds'     : [
        \ 'a:Articles:1:1',
        \ 'b:Books:1:1',
        \ 'L:Booklets:1:1',
        \ 'c:Conferences:1:1',
        \ 'B:Inbook:1:1',
        \ 'C:Incollection:1:1',
        \ 'P:Inproceedings:1:1',
        \ 'm:Manuals:1:1',
        \ 'T:Masterstheses:1:1',
        \ 'M:Misc:1:1',
        \ 't:Phdtheses:1:1',
        \ 'p:Proceedings:1:1',
        \ 'r:Techreports:1:1',
        \ 'u:Unpublished:1:1',
    \ ]
\ }

@raven42
Copy link
Collaborator

raven42 commented Aug 15, 2023

As near as I can tell, there are not child tags under any of these. Is the format of bibtex such that all these tag kinds are at 'global' scope for lack of a better description? Or can there be nested tags? In the example file, it looks like all the tag kinds are at the global scope level and there are no tag kinds for anything inside of those definitions from what I can see.

@andregpss
Copy link
Author

There are no nested tags. References are listed without dependencies between them. Bibtex is a simple list of references.
Documentation is here

@andregpss
Copy link
Author

It is also essential to consider the types introduced by additional packages commonly used on Latex docs.

The main packages are biblatex and natbib.

So, here goes a complete type declaration for Taglib i have created:
gtagbar_type_bib.txt
.

@raven42
Copy link
Collaborator

raven42 commented Aug 15, 2023

I'm hesitant to add kinds that aren't officially supported by ctags. Currently it looks BibTeX is the only bib... language supported by the latest universal-ctags, and the only kinds are the ones I listed. I just pulled the latest universal-ctags and rebuilt from scratch to be sure.

If support is needed for something that universal-ctags does not support itself, then a custom configuration would be needed. For these additional packages you are referencing, do they have a plugin for universal-ctags to add the additional kinds? Without that, even if we defined the extra kinds in our definition, we'd never see them if ctags can't output them.

$ ctags --version
Universal Ctags 6.0.0(p6.0.20230813.0), Copyright (C) 2015-2022 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Aug 15 2023, 14:09:49
  URL: https://ctags.io/
  Output version: 0.0
  Optional compiled features: +wildcards, +regex, +gnulib_regex, +iconv, +option-directory, +xpath, +packcc, +optscript, +pcre2
$ ctags --list-languages | grep -i bib
BibTeX
$ ctags --list-kinds=bibtex
a  article
b  book
B  booklet
c  conference
i  inbook
I  incollection
j  inproceedings
m  manual
M  mastersthesis
n  misc
p  phdthesis
P  proceedings
s  string
t  techreport
u  unpublished
$

For now I'll plan to merge in the changes I have pushed up already, and we can always add more later if needed and ctags support is there.

@andregpss
Copy link
Author

For these additional packages you are referencing, do they have a plugin for universal-ctags to add the additional kinds? Without that, even if we defined the extra kinds in our definition, we'd never see them if ctags can't output them.

I don't know if there is a plugin for u-Ctags to add Bibtex additional kings. I search for it but not find it.

For now I'll plan to merge in the changes I have pushed up already, and we can always add more later if needed and ctags support is there.

When will this merge be available? Thanks.

@raven42
Copy link
Collaborator

raven42 commented Aug 16, 2023

It should be merged into the master branch already. I merged it in yesterday.

@andregpss
Copy link
Author

andregpss commented Aug 16, 2023

Ok. Plug update command update it.

Now Tagbar show misc type. Thank you!

But it is a pity that additional and very popular types such as online are not shown.

@raven42
Copy link
Collaborator

raven42 commented Aug 16, 2023

If you want to open an issue on the universal-ctags github for additional support you can try that. Then if that is supported from the ctags side, we can add support here.

@andregpss
Copy link
Author

universal-ctags now supports biblatex types. I have oppened an issue, and they did it.
Can you please provide that support on Tagbar?
One main example is the support for @online reference. Please note the sequence below:

cat .\references.bib
@online{WinNT,
author = {MultiMedia LLC},
title = {{MS Windows NT} Kernel Description},
year = 1999,
url = {http://web.archive.org/web/20080207010024/http://www.808multimedia.com/winnt/kernel.htm},
urldate = {2010-09-30}
}

https://github.com/Article{autili2012developing,
title={Developing highly complex distributed systems: a software engineering perspective},
author={Autili, Marco and Inverardi, Paola and Pelliccione, Patrizio and Tivoli, Massimo},
journal={Journal of Internet Services and Applications},
volume={3},
number={1},
pages={15--22},
year={2012},
publisher={Springer}
}

@online{Network.Remote.RPC,
author = {Matthew Mirman},
title = {rpc-framework: a remote procedure call framework},
year = {2012},
url = {https://hackage.haskell.org/package/rpc-framework-2.0.0.2},
urldate = {2016-02-29},
note = {Disponível em \url{https://hackage.haskell.org/package/rpc-framework-2.0.0.2}. },
howpublished = {Acesso em 2016-02-29.}
}

ctags --version
Universal Ctags 6.0.0(universal-ctags/ctags@dedfed1), Copyright (C) 2015-2022 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Sep 20 2023, 01:55:08
URL: https://ctags.io/
Output version: 0.0
Optional compiled features: +win32, +wildcards, +regex, +

ctags --options=NONE -o - .\references.bib
ctags.exe: Notice: No options will be read from files or environment
Network.Remote.RPC ./references.bib /^@online{Network.Remote.RPC,$/;" V
WinNT ./references.bib /^@online{WinNT,$/;" V
autili2012developing ./references.bib /^https://github.com/Article{autili2012developing,$/;" a

@raven42 raven42 reopened this Sep 21, 2023
raven42 added a commit that referenced this issue Sep 21, 2023
Fixes #856

Note: VIM does not have a known file extension to differentiate between .bib and a BibLaTeX file. From what I can see, there is no common file-extension for a BibLaTeX file, so a custom filetype configuration will be needed in vim to differentiate between the two.
@raven42
Copy link
Collaborator

raven42 commented Sep 21, 2023

@andregpss I merged in the support for this. Note however, that vim does not have a recognized file extension type for biblatex files so a custom definition is needed. I've updated the doc page in the *tagbar-extend* block, and updated the Wiki page with a new entry for biblatex (https://github.com/preservim/tagbar/wiki#biblatex).

With this change, the online references are showing up in tagbar for the sample file you provided.

image

@andregpss
Copy link
Author

@raven42 Universal-CTags developer asked me to show you this message about BibLatex support. Thanks.

@raven42
Copy link
Collaborator

raven42 commented Sep 23, 2023

Thanks @andregpss let me know if pulled the latest and if you got it working with my merged code. If you have any issues, let me know.

@andregpss
Copy link
Author

@raven42 I have updated Tagbar by executing :PlugUpdate. Now I have the following screen. The article reference is not listed on Tagbar. I have noticed that all Bibtex standard types references are not shown, e.g., article, inproceedings, etc.

image

@raven42
Copy link
Collaborator

raven42 commented Sep 24, 2023

This is intentional. The universal-ctags implementation was done by defining a new tag kind of biblatex that is independent and incompatible with bibtex. Take for example the 'B' kind. In the bor.al bibtex definition, this is defined as 'Inbook', but in the biblatex definition, it is 'Audio' From the tagbar perspective, we have to have only a single language definition, especially if we have overlapping kinds like this. I'm not sure how we would merge the two effectively and accurately given yhe way it was implemented in universal-ctags.

@andregpss
Copy link
Author

andregpss commented Sep 25, 2023

Biblatex adds new types to Bibtex. Biblatex support should include the Bibtex standard types. According to your message, how universal tags implement Biblatex does not make sense. It is better to Tagbar support Bibtex than Biblatex. I will discuss it with universal-ctags developer.

@raven42
Copy link
Collaborator

raven42 commented Sep 25, 2023

Hmm... ok it appears that universal-ctags is using both the bibtex and biblatex parsers when processing a .bib file. Even if the language type is forced to just bibtex. I'm not sure if this is by design or not, but we can try to accommodate in tagbar.

tagbar-test-files$ ctags --extras=+F -f - --format=2 --excmd=pattern --fields=nksSafet --sort=no --append=no -V --language-force=bibtex --bibtex-kinds=abBciIjmMnpPstu
  Option: --language-force=bibtex
  Option: --bibtex-kinds=abBciIjmMnpPstu
Initialize parser: BibTeX
Initialize parser: BibLaTeX
enable field "name": yes
enable field "input": yes
enable field "pattern": yes
Reading command line arguments
OPENING test.bib as BibTeX language file [new]
emmerich2000software    test.bib        /^@inproceedings{emmerich2000software,$/;"      j       line:1
schmidt1996pattern      test.bib        /^@misc{schmidt1996pattern,$/;" n       line:10
trilla2015improving     test.bib        /^@inproceedings{trilla2015improving,$/;"       j       line:17
marlow2009runtime       test.bib        /^@inproceedings{marlow2009runtime,$/;" j       line:26
hickey2008clojure       test.bib        /^@inproceedings{hickey2008clojure,$/;" j       line:36
jones2003haskell        test.bib        /^@book{jones2003haskell,$/;"   b       line:44
currying        test.bib        /^@online{currying,$/;" V       line:51
merrick2006xml  test.bib        /^@misc{merrick2006xml,$/;"     n       line:61
morley2014json  test.bib        /^@misc{morley2014json,$/;"     n       line:69
vanbrabant2008google    test.bib        /^@book{vanbrabant2008google,$/;"       b       line:76
appeltauer2011contextj  test.bib        /^@Article{appeltauer2011contextj,$/;"  a       line:83
siriwardena2013enterprise       test.bib        /^@book{siriwardena2013enterprise,$/;"  b       line:94
tagbar-test-files$

I can update the existing .bib kinds to include at least the non-conflicting entries from the bibtex definition. The following will not be able to be included though as they conflict with existing tag kinds for the bibtex language type.

B:audios
I:datasets
M:legislations
P:movies
i:references
j:reports
m:software
n:standards
p:suppcollections
s:videos
t:xdatas

@raven42 raven42 reopened this Sep 25, 2023
raven42 added a commit to raven42/tagbar that referenced this issue Sep 25, 2023
Closes preservim#856

The universal-ctags update includes both the bibtex and biblatex parser
when processing a .bib file even when language is forced. This will merge
the two as much as possible. There are a number of conflicts and will
use the bibtex standard type in that instance.
raven42 added a commit that referenced this issue Sep 25, 2023
Closes #856

The universal-ctags update includes both the bibtex and biblatex parser
when processing a .bib file even when language is forced. This will merge
the two as much as possible. There are a number of conflicts and will
use the bibtex standard type in that instance.
@raven42
Copy link
Collaborator

raven42 commented Sep 25, 2023

@andregpss Ok I pushed in another change that merges the bibtex and biblatex versions as much as possible. Give the latest a shot and let me know how it goes. As I stated in my last comment, there are a number of biblatex kinds that conflict with the bibtex kinds, so in those instances I used the bibtex kind definition.

@andregpss
Copy link
Author

@raven42 This new update satisfies me. Tagbar now includes all bibtex and partial biblatex references. Thanks!
By the way, universal-ctags developer commented about "running multiple parsers on an input file". It may be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants