All,
I'd like to be able to use the Vim Tagbar plugin with markdown2ctags to navigate my markdown files.
I haven't been able to automatically generate the tags file because the filetype, per :set filetype? is currently set to pandoc. That's becaue I have the the vim-pandoc plugin installed. However, if I change the filtype to markdown everything works.
I have control over two items: my ~/.vimrc file and my ~/.ctags file. Does anyone have an idea of how things should be set? I've tried changing markdown to pandoc in the excerpts below, but that didn't help.
Edit: As per the comment by @IngoKarkat, because markdown2ctags is handling the creation of my tags file, the .ctags settings are irrelevant.
From my ~/.vimrc file... (set as per the Tagbar instructions for markdown files)
let g:tagbar_type_markdown = {
\ 'ctagstype': 'markdown',
\ 'ctagsbin' : '~/.vim/plugged/markdown2ctags/markdown2ctags.py',
\ 'ctagsargs' : '-f - --sort=yes --sro=»',
\ 'kinds' : [
\ 's:sections',
\ 'i:images'
\ ],
\ 'sro' : '»',
\ 'kind2scope' : {
\ 's' : 'section',
\ },
\ 'sort': 0
\ }
...and my ~/.ctags file (Edit: Unused, but still including)
--langdef=markdown
--langmap=markdown:.mkd
--regex-markdown=/^#[ \t]+(.*)/\1/h,Heading_L1/
--regex-markdown=/^##[ \t]+(.*)/\1/i,Heading_L2/
--regex-markdown=/^###[ \t]+(.*)/\1/k,Heading_L3/
Thanks,
Sean
I found a few solutions to the problem. I've listed them here in case someone finds them useful.
Solution 1: Re-define the
pandocfiletype to themarkdownfiletypeI looked at the
vim-pandocpandoc.txt file and the solution was there. The relevant information:With the filetype now correctly set, everything works. The
~/.vimrcshould be (with appropriate substitution for your ownctagsbinpath):Solution 2: Define a new
pandoctagbar typeAdd the following to your
~/.vimrcEverything should work! This is my preferred solution.
Solution 3: Use the builtin
pandoc:TOCcommand.The
vim-pandoc:TOCcommand produces a navigational menu, however, I don't like it as well as the sidebar tagbar menus. But it is a built in default.