- Universal Ctagsを導入して(La)TeX文書で
:Denite outline
を使いたい - 候補は表示されるが,ジャンプが働かない
Universal Ctagsの出力する正規表現に問題があるっぽい?--excmd=number
で行番号の出力にすればOK
以下のような(よくある)TeX文書を用意する.
\documentclass{article}
\begin{document}
\section{Introduction}
\section{Related works}
\section{Proposed method}
\section{Numerical experiments}
\section{Conclusion}
\end{document}
Universal Ctagsを導入した上で, NeoVIM上で :Denite outline
して,適当にsectionを選択してreturnするが該当箇所にジャンプしない.
上記のTeXソースに対してctags hoge.tex
した結果が以下である.
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /3480c6d/
Conclusion test.tex /^\\section{Conclusion}$/;" s
Introduction test.tex /^\\section{Introduction}$/;" s
Numerical experiments test.tex /^\\section{Numerical experiments}$/;" s
Proposed method test.tex /^\\section{Proposed method}$/;" s
Related works test.tex /^\\section{Related works}$/;" s
\section{****}
の\
がエスケープされて\\section{****}
になっている.
tagsを手動で編集し,\\
を\
にしてみる.
すると, :Denite tag
では該当箇所にジャンプするようになった.
Universal Ctagsがtagsに出力する正規表現をエスケープしないようにできれば一番手っ取り早くこの問題を解決できそうだが, Universal Ctagsにそのようなオプションはあるのだろうか.
Universal-ctagsのIssueに以下のようなものがあった.
曰く, --excmd=number
を使えばいいと思うよ,と.
% ctags --excmd=number foo.tex
% cat tags
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /befcb888/
Conclusion foo.tex 13;" s
Introduction foo.tex 5;" s
Numerical experiments foo.tex 11;" s
Proposed method foo.tex 9;" s
Related works foo.tex 7;" s
Deniteのoutline sourceに突っ込んでみる. デフォルトではオプションは空になっているので,あらかじめ
call denite#custom#var('outline', 'options', ['--excmd=number'])
でオプションを登録しておく.
結果は省略するが,当初の目的を達成することができた.