ctagsとtaglistをLatexに対応させる

いわゆるExuberant ctagsはコード解析とかに使われる。vimだと関数が定義されている場所にジャンプできたりして便利。vimプラグインのtaglistを使えばctagsで作ったタグ一覧を表示させて、その一覧から選んでジャンプできる。でもLatexではデフォルトで使えない。

設定を追加すれば使える。まずはctags。ホームディレクトリの~/.ctagsに

--langdef=latex
--langmap=latex:.tex
--regex-latex=/\\label\{([^}]*)\}/\1/l,label/
--regex-latex=/\\chapter\{([^}]*)\}/\1/c,chapter/
--regex-latex=/\\section\{([^}]*)\}/\1/s,section/
--regex-latex=/\\subsection\{([^}]*)\}/\1/t,subsection/
--regex-latex=/\\subsubsection\{([^}]*)\}/\1/u,subsubsection/
--regex-latex=/\\chapter\*\{([^}]*)\}/\1/c,chapter/
--regex-latex=/\\section\*\{([^}]*)\}/\1/s,section/
--regex-latex=/\\subsection\*\{([^}]*)\}/\1/t,subsection/
--regex-latex=/\\subsubsection\*\{([^}]*)\}/\1/u,subsubsection/

を書く。次にvimのtaglistプラグインの設定。

let tlist_tex_settings = 'latex;l:labels;c:chapter;s:sections;t:subsections;u:subsubsections'
set iskeyword=@,48-57,_,-,:,192-255

参考 Simple latex ctags and taglist | Caffeinated Code

iskeywordは上のリンクでも軽く言及されてるけどこちらに解説がある

'iskeyword'とは何なのか - LeafCage備忘録