Smark is a NeoVim plugin that helps you write and manipulate markdown lists. It has an opinionated design with the following principles:
- Correct: only consider and always output valid Markdown lists that have a sane structure (e.g. list block is a clean tree, no sudden jumps in indentation level, correct numbering)
- Clean: follow Prettier's style convention
- Smart: Automatically infer as much as possible
With lazy.nvim:
return {
{
"yutanagano/smark.nvim",
ft = { "markdown", "text" },
--Below are the default settings for the available options. You can omit
--the opts table below and simply set config = true if you are happy with
--the default settings.
opts = {
--Keymapping settings for list action commands.
--Set to false to disable.
mappings = {
--Format the current list block to be clean / correct.
format_list = "<leader>lf",
--Switch between ordered / unordered list types.
toggle_ordered = "<leader>lo",
--Toggle the completion status of a task list item.
toggle_completion = "<leader>lx",
--Toggle between plain and task list items.
toggle_task = "<leader>lt",
},
--Following the starting line of a list item, only contiguous lines that
--start with at least one whitespace character can be considered as part of
--a multi-line list item.
multiline_requires_whitespace = false,
},
}
}Important
The ft = { "markdown", "text" } setting ensures the plugin is lazily loaded
only after NeoVim opens a markdown or plain text buffer. However, regardless
of lazy loading, the plugin is only active when editing markdown or plain
text documents.
I take a lot of Markdown notes in NeoVim. I'm lazy, so 1. I don't like to think about formatting, and 2. I don't want to have to write out lists manually. For the first problem, I use conform.nvim and prettierd to auto-format my Markdown documents at write-time. For the second problem, I previously used the wonderful plugin bullets.vim. I love it, but one thing annoyed me - it didn't play well with Prettier's auto-formatting of lists, specifically the list indentation levels. So, I wrote my own auto-bullet plugin that auto-completes lists in a Prettier-compatible way, which became smark.
Note
Prettier formats nested Markdown lists so that the child list marker aligns with the content of the parent list item, resulting in 2 spaces for unordered lists and enough spaces (usually 3 or more) for ordered lists.
- Foo:
- Bar
1. Foo
1. Bar
2. Foo
3. Foo
4. Foo
5. Foo
6. Foo
7. Foo
8. Foo
9. Foo
10. Foo:
1. Bar- A less opinionated alternative plugin: Bullets.vim
- Hyperlinking Markdown documents: markdown-oxide, marksman
- Render Markdown within NeoVim: render-markdown.nvim
- This plugin is tested using mini.test










