|
1 | | -vim.pack.add { "https://github.com/MeanderingProgrammer/render-markdown.nvim" } |
2 | | --------------------------------------------------------------------------------- |
3 | | - |
4 | | -require("config.utils").pluginKeymaps { |
5 | | - |
| 1 | +vim.pack.add { |
| 2 | + "https://github.com/echasnovski/mini.icons", |
| 3 | + "https://github.com/MeanderingProgrammer/render-markdown.nvim", |
6 | 4 | } |
7 | | - |
8 | 5 | -------------------------------------------------------------------------------- |
9 | 6 |
|
| 7 | +vim.api.nvim_create_autocmd("FileType", { |
| 8 | + pattern = "markdown", |
| 9 | + callback = function(ctx) |
| 10 | + vim.keymap.set( |
| 11 | + "n", |
| 12 | + "<leader>oc", |
| 13 | + function() require("render-markdown").toggle() end, |
| 14 | + { desc = " Markdown render", buffer = ctx.buf } |
| 15 | + ) |
| 16 | + end, |
| 17 | +}) |
| 18 | + |
10 | 19 | require("render-markdown").setup { |
11 | | -quote = { |
12 | | - repeat_linebreak = true, -- full border on soft-wrap |
13 | | -}, |
14 | | -html = { |
15 | | - comment = { |
16 | | - text = function(ctx) |
17 | | - local text = ctx.text:match("^<!%-%-%s*(.-)%s*%-%->$") |
18 | | - if not text then return "" end |
19 | | - return " " .. text:gsub("\n.*", " ↓↓↓") |
20 | | - end, |
| 20 | + quote = { |
| 21 | + repeat_linebreak = true, -- full border on soft-wrap |
| 22 | + }, |
| 23 | + html = { |
| 24 | + comment = { |
| 25 | + text = function(ctx) |
| 26 | + local text = ctx.text:match("^<!%-%-%s*(.-)%s*%-%->$") |
| 27 | + if not text then return "" end |
| 28 | + return " " .. text:gsub("\n.*", " ↓↓↓") |
| 29 | + end, |
| 30 | + }, |
| 31 | + }, |
| 32 | + pipe_table = { |
| 33 | + border_enabled = true, |
| 34 | + border_virtual = true, -- borders not on empty lines -> preserves blank lines |
21 | 35 | }, |
22 | | -}, |
23 | | -pipe_table = { |
24 | | - border_enabled = true, |
25 | | - border_virtual = true, -- borders not on empty lines -> preserves blank lines |
26 | | -}, |
27 | | -heading = { |
28 | | - position = "inline", -- = remove indentation of headings |
29 | | - width = "block", -- = not full width |
30 | | - min_width = vim.o.textwidth, |
31 | | - icons = { " ", " ", " ", " ", " ", " " }, -- `numeric_x` glyphs |
32 | | - -- icons = { " ", " ", " ", " ", " ", " " }, |
33 | | -}, |
34 | | -dash = { |
35 | | - width = vim.o.textwidth, |
36 | | - priority = 10, -- don't cover codelens from `markdown-oxide` for 1st line of frontmatter |
37 | | -}, |
38 | | -bullet = { |
39 | | - icons = { "◇", "▪️", "▫️" }, -- ◆◇•◦▫️▪️ |
40 | | - ordered_icons = "", -- disable overwriting ordered list numbers with 1-2-3 |
41 | | -}, |
42 | | -checkbox = { |
43 | | - checked = { icon = "" }, |
44 | | - unchecked = { icon = "" }, |
45 | | - custom = { |
46 | | - todo = { rendered = "", raw = "[-]", highlight = "RenderMarkdownInfo" }, |
| 36 | + heading = { |
| 37 | + position = "inline", -- = remove indentation of headings |
| 38 | + width = "block", -- = not full width |
| 39 | + min_width = vim.o.textwidth, |
| 40 | + icons = { " ", " ", " ", " ", " ", " " }, -- `numeric_x` glyphs |
| 41 | + -- icons = { " ", " ", " ", " ", " ", " " }, |
47 | 42 | }, |
48 | | -}, |
49 | | -code = { |
50 | | - position = "left", |
51 | | - width = "block", -- = not full width |
52 | | - min_width = 50, |
53 | | - left_pad = 0, -- better `0` due to uneven padding https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/576#issuecomment-3694595069 |
54 | | - right_pad = 1, |
55 | | - border = "thin", -- use the `above`/`below` chars as is |
56 | | - below = "▔", -- ▀▔ |
57 | | - above = "▁", -- ▃▁ |
58 | | - language_border = "▁", |
59 | | - language_left = "▁▁█", |
60 | | - language_right = "█", |
61 | | - highlight_border = "PmenuThumb", |
62 | | -}, |
63 | | -link = { |
64 | | - -- no icon for internal links, since distinguished via color in |
65 | | - -- `query/markdown_inline/highlights.scm` |
66 | | - hyperlink = "", |
67 | | - wiki = { icon = "" }, |
68 | | - email = " ", |
69 | | - footnote = { icon = " ", superscript = false }, |
| 43 | + dash = { |
| 44 | + width = vim.o.textwidth, |
| 45 | + priority = 10, -- don't cover codelens from `markdown-oxide` for 1st line of frontmatter |
| 46 | + }, |
| 47 | + bullet = { |
| 48 | + icons = { "◇", "▪️", "▫️" }, -- ◆◇•◦▫️▪️ |
| 49 | + ordered_icons = "", -- disable overwriting ordered list numbers with 1-2-3 |
| 50 | + }, |
| 51 | + checkbox = { |
| 52 | + checked = { icon = "" }, |
| 53 | + unchecked = { icon = "" }, |
| 54 | + custom = { |
| 55 | + todo = { rendered = "", raw = "[-]", highlight = "RenderMarkdownInfo" }, |
| 56 | + }, |
| 57 | + }, |
| 58 | + code = { |
| 59 | + position = "left", |
| 60 | + width = "block", -- = not full width |
| 61 | + min_width = 50, |
| 62 | + left_pad = 0, -- better `0` due to uneven padding https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/576#issuecomment-3694595069 |
| 63 | + right_pad = 1, |
| 64 | + border = "thin", -- use the `above`/`below` chars as is |
| 65 | + below = "▔", -- ▀▔ |
| 66 | + above = "▁", -- ▃▁ |
| 67 | + language_border = "▁", |
| 68 | + language_left = "▁▁█", |
| 69 | + language_right = "█", |
| 70 | + highlight_border = "PmenuThumb", |
| 71 | + }, |
| 72 | + link = { |
| 73 | + -- no icon for internal links, since distinguished via color in |
| 74 | + -- `query/markdown_inline/highlights.scm` |
| 75 | + hyperlink = "", |
| 76 | + wiki = { icon = "" }, |
| 77 | + email = " ", |
| 78 | + footnote = { icon = " ", superscript = false }, |
| 79 | + |
| 80 | + custom = { |
| 81 | + web = { icon = " " }, -- for links that do not match a pattern below |
70 | 82 |
|
71 | | - custom = { |
72 | | - web = { icon = " " }, -- for links that do not match a pattern below |
| 83 | + -- news sites |
| 84 | + medium = { pattern = "medium%.com", icon = " " }, -- letter-glyphs are named `alpha_…` |
| 85 | + verge = { pattern = "theverge%.com", icon = " " }, |
| 86 | + techcrunch = { pattern = "techcrunch%.com", icon = " " }, |
| 87 | + wired = { pattern = "wired%.com", icon = " " }, |
| 88 | + nytimes = { pattern = "nytimes%.com", icon = " " }, |
| 89 | + bloomberg = { pattern = "bloomberg%.com", icon = " " }, |
| 90 | + guardian = { pattern = "theguardian%.com", icon = " " }, |
| 91 | + zeit = { pattern = "zeit%.de", icon = " " }, |
| 92 | + spiegel = { pattern = "spiegel%.de", icon = " " }, |
| 93 | + tagesschau = { pattern = "tagesschau%.de", icon = " " }, |
73 | 94 |
|
74 | | - -- news sites |
75 | | - medium = { pattern = "medium%.com", icon = " " }, -- letter-glyphs are named `alpha_…` |
76 | | - verge = { pattern = "theverge%.com", icon = " " }, |
77 | | - techcrunch = { pattern = "techcrunch%.com", icon = " " }, |
78 | | - wired = { pattern = "wired%.com", icon = " " }, |
79 | | - nytimes = { pattern = "nytimes%.com", icon = " " }, |
80 | | - bloomberg = { pattern = "bloomberg%.com", icon = " " }, |
81 | | - guardian = { pattern = "theguardian%.com", icon = " " }, |
82 | | - zeit = { pattern = "zeit%.de", icon = " " }, |
83 | | - spiegel = { pattern = "spiegel%.de", icon = " " }, |
84 | | - tagesschau = { pattern = "tagesschau%.de", icon = " " }, |
| 95 | + -- misc |
| 96 | + openai = { pattern = "openai%.com", icon = " " }, |
| 97 | + doi = { pattern = "doi%.org", icon = " " }, |
| 98 | + mastodon = { pattern = "%.social/@", icon = " " }, |
| 99 | + researchgate = { pattern = "researchgate%.net", icon = " " }, |
| 100 | + my_website = { pattern = "chris%-grieser.de", icon = " " }, |
| 101 | + }, |
| 102 | + }, |
| 103 | + -------------------------------------------------------------------------- |
| 104 | + sign = { enabled = false }, |
| 105 | + render_modes = { "n", "c", "i", "v", "V" }, |
| 106 | + win_options = { |
| 107 | + -- makes toggling this plugin also toggle conceallevel |
| 108 | + conceallevel = { default = 0 }, |
85 | 109 |
|
86 | | - -- misc |
87 | | - openai = { pattern = "openai%.com", icon = " " }, |
88 | | - doi = { pattern = "doi%.org", icon = " " }, |
89 | | - mastodon = { pattern = "%.social/@", icon = " " }, |
90 | | - researchgate = { pattern = "researchgate%.net", icon = " " }, |
91 | | - my_website = { pattern = "chris%-grieser.de", icon = " " }, |
| 110 | + -- disabled on render, since heading width already indicates it |
| 111 | + colorcolumn = { default = vim.o.colorcolumn, rendered = "" }, |
92 | 112 | }, |
93 | | -}, |
94 | | --------------------------------------------------------------------------- |
95 | | -sign = { enabled = false }, |
96 | | -render_modes = { "n", "c", "i", "v", "V" }, |
97 | | -win_options = { |
98 | | - conceallevel = { default = 0 }, -- makes toggling this plugin also toggle conceallevel |
99 | | - colorcolumn = { default = vim.o.colorcolumn, rendered = "" }, -- disabled on render, since heading width already indicates it |
100 | | -}, |
101 | | -overrides = { -- LSP hovers: hide code block lines |
102 | | - buftype = { |
103 | | - nofile = { |
104 | | - code = { border = "hide", style = "normal" }, |
| 113 | + overrides = { -- LSP hovers: hide code block lines |
| 114 | + buftype = { |
| 115 | + nofile = { |
| 116 | + code = { border = "hide", style = "normal" }, |
| 117 | + }, |
105 | 118 | }, |
106 | 119 | }, |
107 | | -}, |
108 | 120 | } |
0 commit comments