Skip to content

Instantly share code, notes, and snippets.

@danmichaelo
Created March 30, 2011 11:56
Show Gist options
  • Select an option

  • Save danmichaelo/894275 to your computer and use it in GitHub Desktop.

Select an option

Save danmichaelo/894275 to your computer and use it in GitHub Desktop.
VimLatex TagList patch
Index: main.vim
===================================================================
--- main.vim (revision 1075)
+++ main.vim (working copy)
@@ -886,7 +886,7 @@
" Sets Tlist_Ctags_Cmd for taglist.vim and regexps for ctags {{{
if exists("g:Tex_TaglistSupport") && g:Tex_TaglistSupport == 1
if !exists("g:tlist_tex_settings")
- let g:tlist_tex_settings = 'tex;s:section;c:chapter;l:label;r:ref'
+ let g:tlist_tex_settings = 'tex;d:Sections;l:Labels;r:References'
endif
if exists("Tlist_Ctags_Cmd")
@@ -897,20 +897,20 @@
if exists("g:Tex_InternalTagsDefinitions") && g:Tex_InternalTagsDefinitions == 1
let Tlist_Ctags_Cmd = s:tex_ctags ." --langdef=tex --langmap=tex:.tex.ltx.latex"
- \.' --regex-tex="/\\\\begin{abstract}/Abstract/s,abstract/"'
- \.' --regex-tex="/\\\\part[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,part/"'
- \.' --regex-tex="/\\\\chapter[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,chapter/"'
- \.' --regex-tex="/\\\\section[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,section/"'
- \.' --regex-tex="/\\\\subsection[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/s,subsection/"'
- \.' --regex-tex="/\\\\subsubsection[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/s,subsubsection/"'
- \.' --regex-tex="/\\\\paragraph[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/s,paragraph/"'
- \.' --regex-tex="/\\\\subparagraph[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/s,subparagraph/"'
- \.' --regex-tex="/\\\\begin{thebibliography}/BIBLIOGRAPHY/s,thebibliography/"'
- \.' --regex-tex="/\\\\tableofcontents/TABLE OF CONTENTS/s,tableofcontents/"'
- \.' --regex-tex="/\\\\frontmatter/FRONTMATTER/s,frontmatter/"'
- \.' --regex-tex="/\\\\mainmatter/MAINMATTER/s,mainmatter/"'
- \.' --regex-tex="/\\\\backmatter/BACKMATTER/s,backmatter/"'
- \.' --regex-tex="/\\\\appendix/APPENDIX/s,appendix/"'
+ \.' --regex-tex="/\\\\begin{abstract}/Abstract/d,abstract/"'
+ \.' --regex-tex="/\\\\part[ \t]*\*?\{[ \t]*([^}]*)\}/\1/d,part/"'
+ \.' --regex-tex="/\\\\chapter[ \t]*\*?\{[ \t]*([^}]*)\}/\1/d,chapter/"'
+ \.' --regex-tex="/\\\\section[ \t]*\*?\{[ \t]*([^}]*)\}/\1/d,section/"'
+ \.' --regex-tex="/\\\\subsection[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/d,subsection/"'
+ \.' --regex-tex="/\\\\subsubsection[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/d,subsubsection/"'
+ \.' --regex-tex="/\\\\paragraph[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/d,paragraph/"'
+ \.' --regex-tex="/\\\\subparagraph[ \t]*\*?\{[ \t]*([^}]*)\}/+ \1/d,subparagraph/"'
+ \.' --regex-tex="/\\\\begin{thebibliography}/BIBLIOGRAPHY/d,thebibliography/"'
+ \.' --regex-tex="/\\\\tableofcontents/TABLE OF CONTENTS/d,tableofcontents/"'
+ \.' --regex-tex="/\\\\frontmatter/FRONTMATTER/d,frontmatter/"'
+ \.' --regex-tex="/\\\\mainmatter/MAINMATTER/d,mainmatter/"'
+ \.' --regex-tex="/\\\\backmatter/BACKMATTER/d,backmatter/"'
+ \.' --regex-tex="/\\\\appendix/APPENDIX/d,appendix/"'
\.' --regex-tex="/\\\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/"'
\.' --regex-tex="/\\\\ref[ \t]*\*?\{[ \t]*([^}]*)\}/\1/r,ref/"'
endif
@danmichaelo
Copy link
Author

I had issues with some TeX section headings showing up twice in Taglist. The cause of the problem was that Vim-LaTeX defines Tex-support for ctags, but my exuberant ctags 5.8 already had some native TeX-support:

$ ctags --list-kinds=tex
c  chapters
s  sections
u  subsections
b  subsubsections
p  parts
P  paragraphs
G  subparagraphs

When Vim-LaTeX tries to define it again on line 899 in main.vim, it results in the error ctags: Warning: Language "tex" already defined.

This error does not influence on TagList by itself, but Vim-LaTeX's definitions add to the native ones. Since the regexps of Vim-LaTeX appear to be more robust than the native ones, I simply modified main.vim to ignore the native definitions by using an unused character ("d") instead of "s" for the all the section-related regexps, and then modified the tlist_tex_settings. This workaround is not very elegant, but it works until someone comes up with something better. The best solution would certainly be a more robust native TeX-support in ctags.

Note that I kept the --langdef=tex argument, even though it results in an error when used with ctags with TeX support. The rationale is that the error does not seem to influence the way Taglist works, and leaving the argument out will break backwards compability.

@danmichaelo
Copy link
Author

Within Vim, this command may be useful:

TlistDebug ~/tlistdebug.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment