mzlogin / vim-markdown-toc

A vim 7.4+ plugin to generate table of contents for Markdown files.
http://www.vim.org/scripts/script.php?script_id=5460
MIT License
613 stars 59 forks source link

GFM ordered list style not honored when using custom list_item_char `1.` #63

Open bratekarate opened 4 years ago

bratekarate commented 4 years ago

First off

Thanks for this great plugin. I know GFMs way of handling ordered lists is pretty weird, but it still would be nice if this plugin could handle it out of the box.

Issue

I want a numbered TOC. I achieved this by following the advice in this issue on vimwiki, setting g:vmt_list_item_char = '1.'.

This seems to work fine, but GFM is acting very rude, requiring 4 whitespaces of indentation in sublevels. To save some energy, I tried not to be so mad about that.

I inserted the following option in my vimrc as a workaround: g:vmt_list_indent_text = repeat(' ', 4). This is good for now, but I think it would be great to support numbered lists in general.

One issue now is, that if I want to change my item char back to e.g. -, I have to change indent text as well, or live with inconsistent indentation in my document, as my usual shiftwidth is 2 for markdown.

Also, if I use this TOC in other markdown formats, where two whitespaces are permitted, my hardcoded intent text will still be picked up.

Feature request

So my minor suggestions, with low prio, is to offer a global flag to generate numbered TOC. Use 1. as a prefix in this case. This global flag could then be checked for in s:GetIndentText. If it's true AND GFM style is used AND &expandtab is not set, don't use the &shiftwidth, but rather 4 whitespaces. Otherwise use tab or shiftwidth.