Использование плагина vims tagbar для латексных файлов
В настоящее время я пытаюсь заставить плагин tagbar для vim работать с латексными файлами в Mac OS X.
Это мой файл ~/.ctags:
--langdef=latex
--langmap=latex:.tex
--regex-latex=/^\\tableofcontents/TABLE OF CONTENTS/s,toc/
--regex-latex=/^\\frontmatter/FRONTMATTER/s,frontmatter/
--regex-latex=/^\\mainmatter/MAINMATTER/s,mainmatter/
--regex-latex=/^\\backmatter/BACKMATTER/s,backmatter/
--regex-latex=/^\\bibliography\{/BIBLIOGRAPHY/s,bibliography/
--regex-latex=/^\\part[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/PART \2/s,part/
--regex-latex=/^\\part[[:space:]]*\*[[:space:]]*\{([^}]+)\}/PART \1/s,part/
--regex-latex=/^\\chapter[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/CHAP \2/s,chapter/
--regex-latex=/^\\chapter[[:space:]]*\*[[:space:]]*\{([^}]+)\}/CHAP \1/s,chapter/
--regex-latex=/^\\section[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\. \2/s,section/
--regex-latex=/^\\section[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\. \1/s,section/
--regex-latex=/^\\subsection[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\.\. \2/s,subsection/
--regex-latex=/^\\subsection[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\.\. \1/s,subsection/
--regex-latex=/^\\subsubsection[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\.\.\. \2/s,subsubsection/
--regex-latex=/^\\subsubsection[[:space:]]*\*[[:space:]]*\{([^}]+)\}/\.\.\. \1/s,subsubsection/
--regex-latex=/^\\includegraphics[[:space:]]*(\[[^]]*\])?[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\3/g,graphic+listing/
--regex-latex=/^\\lstinputlisting[[:space:]]*(\[[^]]*\])?[[:space:]]*(\[[^]]*\])?[[:space:]]*\{([^}]+)\}/\3/g,graphic+listing/
--regex-latex=/\\label[[:space:]]*\{([^}]+)\}/\1/l,label/
--regex-latex=/\\ref[[:space:]]*\{([^}]+)\}/\1/r,ref/
--regex-latex=/\\pageref[[:space:]]*\{([^}]+)\}/\1/p,pageref/
и это соответствующая часть в моем ~/.vimrc:
let g:tagbar_type_tex = {
\ 'ctagstype' : 'latex',
\ 'kinds' : [
\ 's:sections',
\ 'g:graphics:0:0',
\ 'l:labels',
\ 'r:refs:1:0',
\ 'p:pagerefs:1:0'
\ ],
\ 'sort' : 0,
\ }
Я в основном получил все это по этой ссылке: https://github.com/vim-scripts/Tagbar/blob/master/doc/tagbar.txt
К сожалению, когда я запускаю панель тегов, ничего не происходит, и когда я выполняю:UpdateTags я получаю следующую ошибку:
easytags.vim 3.7: Exuberant Ctags doesn't support the 'plaintex' file type! (at function xolox#easytags#update..<SNR>20_check_cfile, line 22)
ctags --version приводит к:
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Oct 1 2014, 16:18:15
Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
и "какие ctags" в:
/usr/local/bin/ctags
Когда я выполняю ctags --verbose abstract.tex, он находит файл ~/.ctags и генерирует этот файл тегов:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
. Abstract abstract.tex /^\\section*{Abstract}$/;" s
Сам файл выглядит так:
\section*{Abstract}
Let's see what we can do here...
Что мне не хватает?:(
С уважением и спасибо за вашу помощь:)
1 ответ
Проблема EasyTags
EasyTags использует тип файла текущего буфера, чтобы определить, какие аргументы он должен передать
ctags
,filetype
вашего файла установлен наplaintex
по умолчанию для Vim*.tex
файлы. Итак... вы получаете эту ошибку, потому чтоplaintex
не признаетсяctags
,
Проблема с тэгбаром
Согласно документации, вы должны использовать
filetype
в вашей пользовательской конфигурации:g:tagbar_type_{vim filetype}
Так как ваш
*.tex
файл распознается какplaintex
, вашg:tagbar_type_tex
никогда не будет использоваться.
Либеральное решение
Добавьте эти строки в свой
~/.vimrc
заставить Вима узнать*.tex
файлы какlatex
:augroup latex autocmd! autocmd BufRead,BufNewFile *.tex set filetype=latex augroup END
Измените свою собственную конфигурацию Tagbar из:
g:tagbar_type_tex
чтобы:
g:tagbar_type_latex
Это решение будет работать, только если Vim настроен на работу с latex
Тип файла (ftplugin, синтаксис, отступ...), который в лучшем случае сомнителен.
Консервативный раствор
использование
plaintex
вместоlatex
в вашем~/.ctags
конфигурация:--langdef=plaintex --langmap=plaintex:.tex --regex-plaintex=/^\\tableofcontents/TABLE OF CONTENTS/s,toc/ ...
Измените свою собственную конфигурацию Tagbar из:
let g:tagbar_type_tex = { \ 'ctagstype' : 'latex', ...
чтобы:
let g:tagbar_type_plaintex = { \ 'ctagstype' : 'plaintex', ...