aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpseudometa <73286100+chrisgrieser@users.noreply.github.com>2023-09-25 19:56:15 +0200
committerGitHub <noreply@github.com>2023-09-25 10:56:15 -0700
commitde58b06d434047c6ecd5ec2d52877335d37b05fd (patch)
tree1df436536c9e7c0bf43978766cf1e0867a11b91f
parent34daf23415e9d212697f79506039498db2b35240 (diff)
feat: add `markdown-toc` (#75)
* feat: add `markdown-toc` * fix: ran stylua * fix: correct indent when formatting in different buffer
-rw-r--r--lua/conform/formatters/markdown-toc.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/lua/conform/formatters/markdown-toc.lua b/lua/conform/formatters/markdown-toc.lua
new file mode 100644
index 0000000..129d50e
--- /dev/null
+++ b/lua/conform/formatters/markdown-toc.lua
@@ -0,0 +1,15 @@
+---@type conform.FileFormatterConfig
+return {
+ meta = {
+ url = "https://github.com/jonschlinkert/markdown-toc",
+ description = "API and CLI for generating a markdown TOC (table of contents) for a README or any markdown files.",
+ },
+ command = "markdown-toc",
+ stdin = false,
+ args = function(ctx)
+ -- use the indentation set in the current buffer, effectively allowing us to
+ -- use values from .editorconfig
+ local indent = vim.bo[ctx.buf].expandtab and (" "):rep(vim.bo[ctx.buf].tabstop) or "\t"
+ return { "--indent=" .. indent, "-i", "$FILENAME" }
+ end,
+}