2011-08-12 49 views
3

我嘗試爲wiki-file = vimwiki創建標籤。 這是我的ctags定義,存儲爲ctags.cnfctags,vimwiki,vim和tagbar-plugin

--langdef=vimwiki 
--langmap=vimwiki:.wiki 
--regex-vimwiki=/^=[ \t]+(.*)/\1/h,heading1/ 
--regex-vimwiki=/^==[ \t]+(.*)/2-\1/h,heading2/ 
--regex-vimwiki=/^===[ \t]+(.*)/3-\1/h,heading3/ 
--regex-vimwiki=/^====[ \t]+(.*)/4-\1/h,heading4/ 

調用ctags --verbose index.wiki結果:

... 
Considering option file .\ctags.cnf: reading... 
    Option: --langdef=vimwiki 
    Option: --langmap=vimwiki:.wiki 
    Setting vimwiki language map: .wiki 
    Option: --regex-vimwiki=/^=[ \t]+(.*)/\1/h,heading1/ 
    Option: --regex-vimwiki=/^==[ \t]+(.*)/2-\1/h,heading2/ 
    Option: --regex-vimwiki=/^===[ \t]+(.*)/3-\1/h,heading3/ 
    Option: --regex-vimwiki=/^====[ \t]+(.*)/4-\1/h,heading4/ 
Reading initial options from command line 
Reading command line arguments 
OPENING index.wiki as vimwiki language file 
sorting tag file 

生成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_PROGRAM_AUTHOR Darren Hiebert /[email protected]/ 
!_TAG_PROGRAM_NAME Exuberant Ctags // 
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ 
!_TAG_PROGRAM_VERSION 5.8 // 
2-!KnowledgeBase == index.wiki /^== !KnowledgeBase ==$/;" h 
2-Dokumentation == index.wiki /^== Dokumentation ==$/;" h 
2-Entwicklung == index.wiki /^== Entwicklung ==$/;" h 
2-Essential Tools == index.wiki /^== Essential Tools ==$/;" h 
2-TODO == index.wiki /^== TODO ==$/;" h 
2-Vim-Mode in shell/bash /zsh == index.wiki /^== Vim-Mode in shell \/ bash \/zsh ==$/;" h 
[email protected] === index.wiki /^=== @home ===$/;" h 
3-Clojure === index.wiki /^=== Clojure ===$/;" h 
3-HTML5 & CSS3 === index.wiki /^=== HTML5 & CSS3 ===$/;" h 
3-LaTeX === index.wiki /^=== LaTeX ===$/;" h 
3-Online-Tools === index.wiki /^=== Online-Tools ===$/;" h 
3-Open Source === index.wiki /^=== Open Source ===$/;" h 
3-Vim === index.wiki /^=== Vim ===$/;" h 
3-Wetware === index.wiki /^=== Wetware ===$/;" h 
4-git ==== index.wiki /^==== git ====$/;" h 
4-nosql ==== index.wiki /^==== nosql ====$/;" h 
Self Org = index.wiki /^= Self Org =$/;" h 

在我_vimrc我加入

let g:tagbar_type_wiki = { 
\ 'ctagstype' : 'vimwiki', 
\ 'kinds'  : [ 
\ 'h:headings' 
\ ], 
\ 'sort' : 0, 
\ 'deffile' : expand('<sfile>:p:h:h') . 'c:\\d\\ctags.cnf' 
\ } 

打開index.wiki和:TagbarToggle只打開一個空的標記欄。

我的錯誤在哪裏?

+0

什麼是你'filetype'設置設定爲維基文件? Tagbar配置假定它被設置爲'wiki',但是這真是'set filetype?'報告的內容嗎?如果你的ctags.cnf位於標準位置,你也不需要'deffile'設置,它只適用於其他文件。 –

+0

filetype是解決方案。 tyvm! – vbd

+0

這是一個相當古老的問題,但仍然在搜索早期出現。 FWIW vimwiki和tagbar的「官方」版本由vimwiki dev發佈[這裏](https://github.com/vimwiki/utils/blob/master/vwtags.py)。 – Sparhawk

回答

4
  • 感謝Jan Larres提示:echo &ft我找到了解決方案。
  • ctags.cnf移動到用戶配置文件路徑也是有用的。

我的更新_vimrc

let g:tagbar_type_vimwiki = { 
\ 'ctagstype' : 'vimwiki', 
\ 'kinds'  : [ 
\ 'h:header', 
\ ], 
\ 'sort' : 0 
\ } 

和我的更新ctags.cnf

--langdef=vimwiki 
--langmap=vimwiki:.wiki 
--regex-vimwiki=/^=[ \t]+(.+)[ \t]+=$/\1/h,header/ 
--regex-vimwiki=/^==[ \t]+(.+)[ \t]+==$/. \1/h,header/ 
--regex-vimwiki=/^===[ \t]+(.+)[ \t]+===$/. \1/h,header/ 
--regex-vimwiki=/^====[ \t]+(.+)[ \t]+====$/.  \1/h,header/ 
--regex-vimwiki=/^=====[ \t]+(.+)[ \t]+=====$/.  \1/h,header/ 
--regex-vimwiki=/^======[ \t]+(.+)[ \t]+======$/.   \1/h,header/