]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lang/markdown.lua
lazyvim: absorb all langs
[dotfiles.git] / nvim / lua / plugins / lang / markdown.lua
1 return {
2 {
3 "stevearc/conform.nvim",
4 optional = true,
5 opts = {
6 formatters = {
7 ["markdown-toc"] = {
8 condition = function(_, ctx)
9 for _, line in ipairs(vim.api.nvim_buf_get_lines(ctx.buf, 0, -1, false)) do
10 if line:find("<!%-%- toc %-%->") then
11 return true
12 end
13 end
14 end,
15 },
16 ["markdownlint-cli2"] = {
17 condition = function(_, ctx)
18 local diag = vim.tbl_filter(function(d)
19 return d.source == "markdownlint"
20 end, vim.diagnostic.get(ctx.buf))
21 return #diag > 0
22 end,
23 },
24 },
25 formatters_by_ft = {
26 ["markdown"] = { "prettier", "markdownlint-cli2", "markdown-toc" },
27 ["markdown.mdx"] = { "prettier", "markdownlint-cli2", "markdown-toc" },
28 },
29 },
30 },
31 {
32 "williamboman/mason.nvim",
33 opts = { ensure_installed = { "markdownlint-cli2", "markdown-toc" } },
34 },
35 {
36 "nvimtools/none-ls.nvim",
37 optional = true,
38 opts = function(_, opts)
39 local nls = require("null-ls")
40 opts.sources = vim.list_extend(opts.sources or {}, {
41 nls.builtins.diagnostics.markdownlint_cli2,
42 })
43 end,
44 },
45 {
46 "mfussenegger/nvim-lint",
47 optional = true,
48 opts = {
49 linters_by_ft = {
50 markdown = { "markdownlint-cli2" },
51 },
52 },
53 },
54 {
55 "neovim/nvim-lspconfig",
56 opts = {
57 servers = {
58 marksman = {},
59 },
60 },
61 },
62
63 -- Markdown preview
64 {
65 "iamcco/markdown-preview.nvim",
66 cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
67 build = function()
68 require("lazy").load({ plugins = { "markdown-preview.nvim" } })
69 vim.fn["mkdp#util#install"]()
70 end,
71 keys = {
72 {
73 "<leader>cp",
74 ft = "markdown",
75 "<cmd>MarkdownPreviewToggle<cr>",
76 desc = "Markdown Preview",
77 },
78 },
79 config = function()
80 vim.cmd([[do FileType]])
81 end,
82 },
83
84 {
85 "MeanderingProgrammer/render-markdown.nvim",
86 opts = {
87 code = {
88 sign = false,
89 width = "block",
90 right_pad = 1,
91 },
92 heading = {
93 sign = false,
94 icons = {},
95 },
96 checkbox = {
97 enabled = false,
98 },
99 },
100 ft = { "markdown", "norg", "rmd", "org", "codecompanion" },
101 config = function(_, opts)
102 require("render-markdown").setup(opts)
103 Snacks.toggle({
104 name = "Render Markdown",
105 get = function()
106 return require("render-markdown.state").enabled
107 end,
108 set = function(enabled)
109 local m = require("render-markdown")
110 if enabled then
111 m.enable()
112 else
113 m.disable()
114 end
115 end,
116 }):map("<leader>um")
117 end,
118 },
119 }