You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Comment yaml block in markdown with different character #15
Many markdown implementations allow for a leading yaml configuration block like so:
---
title: "My title"
date: 2023-12-29
---
## Heading
Some markdown text
With the vim commentary plugin, I can setup vim to use html comment strings (<!-- %s --> ) for the markdown file, but I can't figure out how to automatically switch to a leading # when commenting in the yaml code block. I tried this pluging but could not get it to work for this scenario, how do I need to change the settings?
Additionally: note that this plugin leverages the syntax highlighting of the file format, as explained in the docs. If the syntax highlighting of the format is not able to match when it's the YAML frontmatter or when it's Markdown, it just won't work. I did a quick test, and with my syntax highlighting (whatever is the default on nvim 0.7.2), it is not supported because that syntax highlighting is oblivious to it.
Thanks for the response @suy! It seems like the regions are detected for me as pandocYAMLHeader (likely via my pandoc plugin)
But when I try adding the following
let g:context#commentstring#table.pandoc = { 'pandocYAMLHeader' : '# %s' }
to my vimrc, it does not have an effect on changing the commentstring.
Interestingly, even without vim-context-commentstring installed the yaml commenting is working as I want in files with the extension .qmd (quarto filetype) but not in .md (markdown filetype) files.
I don't know enough of your setup, but I did a quick try with the pandoc syntax, and call extend(g:context#commentstring#table, {'pandoc': {'pandocYAMLHeader': '# %s'}}) to add an extra rule to the table. After I do setfiletype pandoc.markdown, the changes apply, and I can comment out the text with <!-- --> and the frontmatter with #.
I don't remember VimL that much to know if the issue might be in how you extend the g:context#commentstring#table dictionary, or if the issue might be the file type (according to the docs of the plugin I linked, the file type should be pandoc.markdown for when using it "manually", without the other pandoc plugin). This might not be the same for you, I don't know.
Activity
suy commentedon Dec 30, 2023
Have you seen the "customization" section of the docs?
suy commentedon Dec 30, 2023
Additionally: note that this plugin leverages the syntax highlighting of the file format, as explained in the docs. If the syntax highlighting of the format is not able to match when it's the YAML frontmatter or when it's Markdown, it just won't work. I did a quick test, and with my syntax highlighting (whatever is the default on nvim 0.7.2), it is not supported because that syntax highlighting is oblivious to it.
joelostblom commentedon Dec 30, 2023
Thanks for the response @suy! It seems like the regions are detected for me as
pandocYAMLHeader(likely via my pandoc plugin)But when I try adding the following
to my vimrc, it does not have an effect on changing the commentstring.
Interestingly, even without
vim-context-commentstringinstalled the yaml commenting is working as I want in files with the extension.qmd(quarto filetype) but not in.md(markdown filetype) files.suy commentedon Dec 31, 2023
I don't know enough of your setup, but I did a quick try with the pandoc syntax, and
call extend(g:context#commentstring#table, {'pandoc': {'pandocYAMLHeader': '# %s'}})to add an extra rule to the table. After I dosetfiletype pandoc.markdown, the changes apply, and I can comment out the text with<!-- -->and the frontmatter with#.I don't remember VimL that much to know if the issue might be in how you extend the
g:context#commentstring#tabledictionary, or if the issue might be the file type (according to the docs of the plugin I linked, the file type should bepandoc.markdownfor when using it "manually", without the other pandoc plugin). This might not be the same for you, I don't know.I hope this helps.