-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Vimdoc writer #11132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vimdoc writer #11132
Conversation
Support for vimdoc, documentation format used by vim in its help pages Relies heavily on definition lists and precise text alignment to generate tags
I reckon this is correct behavior, because traditionally vim help pages have 78 characters limit, so that if tag with two concealed stars is right-aligned, the result still fits in 80 characters. You can UPD: I gave it a second look and help pages bundled with vim. Headers that contain tag put the tag starting at column 57 (so 22 characters are reserved for unconcealed tag). Neovim help pages are not so consistent (see eg. api.txt). I would still right-align tags, because it looks nice and renders correctly when writerColumns=78 and terminal width is 80 I also found out that |
Regarding CI failure, I see it say that forM is redundant, but I don't get any warnings when building (and HLS does not report any either), if I remove the import, I get compilation error. I am doing |
Clean build with ghc 9.8.4 produced no warnings. Installing ghc 9.0.2 right now to see if it changes anything |
Turns out with older GHCs Control.Monad.{Reader,Writer} reexport |
This is strong, and so is this. | ||
|
||
An emphasized link /url. | ||
|
||
This is strong and em. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there's no emphasis in vimdoc? Would it make sense to just use the markdown conventions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*italicized*
and **strengthened**
would be treated as references and concealed, and I am personally not a fan of _italicized_
and __strengthened__
underscore-style.
Subjectively ~~deleted~~
is not so bad, but in vim ~~text~~
will become ~~text~
with helpHeader
highlight group if it happens to be the last word in the line. Neovim does not suffer from this due to treesitter highlighting


Copied replaceSpecialStrings from Org writer and modified it to remove soft hyphens
Have you put the extra test files in pandoc.cabal's extra-source-files stanza? A good way to check that you have everything needed there is to do |
Nope, missed that, will fix now |
Great, thanks! |
Hello, this PR adds support for writing vimdoc, documentation format used by vim in its help pages.
Vimdoc is very loose and does not have a formal spec, best I could afford as a reference are vim’s/neovim’s help pages,
:h help-writing
, neovim’s treesitter grammar for vimdoc (including highlights.scm), and panvimdoc.When I decided to conjure the vimdoc writer I found panvimdoc which implements vimdoc generation as a custom writer, but having robust solution built-in is better.
To generate idiomatic vimdoc, the writer relies heavily on definition lists, because if we look at the fragment of options.txt, we see
or fragment from
treesitter.txt
:Definition lists are everywhere and they always have tags.
Tags are important because vim’s documentation system is mostly based on the idea that you can quickly find information via
:help tag
. Problem with tags is that each tag should be unique, so each tag is prefixed withvimdoc-prefix
metadata var if it is present, and left intact otherwise.converts to
Notice how tags exceed writerColumns by two. This is because stars surrounding tags are concealed when viewing help pages in vim/neovim.
Vim also expects help files to start with a
$filename.txt<Tab>$ShortDescription
, so another variable is expected –filename
which paired withabstract
produces said format. See [test/vimdoc/definition-lists.vimdoc].I added golden tests for vimdoc writer including new vimdoc-specific ones:
I am obviously open to changes because it is my first attempt at producing a pandoc writer, previously I have only written a couple of lua filters.
I haven’t written any documentation (despite creating the writer to help others write documentation 😄) because I would like to get approval on the code first.
Disclosure: I used an LLM to prototype TOC generation. This is the only place where I used AI, and later it was heavily refactored by hand.
Current limitations
gO
BlockQuote
s,Quoted
,Cite
and figures. For now blockquotes are simply blocks prefixed with"| "
, quotes andCite
s are rendered as is with formatting stripped.~
so that this line is highlighted.${{math}}$