vbd
vbd

Reputation: 3557

ctags, vimwiki, vim and tagbar-plugin

I try to create tags for a wiki-file = vimwiki. This is my definition for ctags, stored as ctags.cnf

--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/

Calling ctags --verbose index.wiki results in:

...
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

The generated tags file shows this:

!_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
3-@home === 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 

In my _vimrc i added

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

Opening index.wiki and :TagbarToggle opens only a empty tagbar.

Where's my error?

Upvotes: 3

Views: 3098

Answers (1)

vbd
vbd

Reputation: 3557

  • thanks to Jan Larres hint with :echo &ft I found the solution.
  • moving ctags.cnf to the user profile path is useful, too.

My updated _vimrc

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

and my updated 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/ 

Upvotes: 7

Related Questions