Closed ben-grande closed 4 months ago
Thanks for your advice.
But in my opinion, there's no need to do this.
According to my understanding, the intention of the recommendations in Google Markdown style guide is for text alignment, especially when lists and wrapped text are mixed. But the auto generated toc are all lists, no wrapped text, so the text at the same level is always aligned.
For example, there is a complex auto generated toc in https://raw.githubusercontent.com/mzlogin/awesome-adb/master/README.en.md, I think the text alignment and readability are OK.
If you think there's no need for this, I won't debate, but I have a hacky solution locally though, without a new option, just enforcing the addition of spaces after list chars:
diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim
index c8bcaaf..28bbb2a 100644
--- a/ftplugin/markdown.vim
+++ b/ftplugin/markdown.vim
@@ -309,16 +309,23 @@ function! s:GenTocInner(markdownStyle, isModeline)
if l:levels[i] <= g:vmt_max_level && l:levels[i] >= g:vmt_min_level
let l:headingIndents = l:levels[i] - l:minLevel
let l:listItemChar = l:listItemChars[(l:levels[i] + 1) % len(l:listItemChars)]
+ if len(l:listItemChars) == 1
+ let l:listSpaceAfterItemChar = " "
+ elseif len(l:listItemChars) == 2
+ let l:listSpaceAfterItemChar = " "
+ endif
" make link if desired, otherwise just bullets
if g:vmt_link
let l:headingLink = <SID>GetHeadingLink(l:headingName, a:markdownStyle)
let l:heading = repeat(s:GetIndentText(), l:headingIndents)
let l:heading = l:heading . l:listItemChar
+ let l:heading = l:heading . l:listSpaceAfterItemChar
let l:heading = l:heading . " [" . l:headingName . "]"
let l:heading = l:heading . "(#" . l:headingLink . ")"
else
let l:heading = repeat(s:GetIndentText(), l:headingIndents)
let l:heading = l:heading . l:listItemChar
+ let l:heading = l:heading . l:listSpaceAfterItemChar
let l:heading = l:heading . " " . l:headingName
endif
silent put =l:heading
Not anywhere code complete, just a scratch, improvements would be to add an option via global variable and use a function also.
See how it looks on single line lists
Thanks anyway for evaluating my proposal and sorry for the many grammar errors above.
If you still feel it is not necessary, although it could be an optional feature instead of default, can close this issue.
Your example file looks good.
While I probably wouldn't adopt this style, I thought adding an option might help someone like you.
Now you can update the plugin to the lastest version, and add an setting line to your vimrc file.
let g:vmt_list_flag_min_width = 4
Thank you very much, an elegant solution. Tested and it works.
The Google Markdown style guide recommend to indent the list lines after the character they are to 2 spaces after ordered list or 3 spaces after unordered list.
Can you please add an option do specify number of spaces after the list character?