diff --git a/README.md b/README.md index 1da296d..1bd62e5 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ require('render-markdown').setup({ -- Executable used to convert latex formula to rendered unicode converter = 'latex2text', -- Highlight for LaTeX blocks - highlight = '@markup.math', + highlight = 'RenderMarkdownMath', }, heading = { -- Turn on / off heading icon & background rendering @@ -199,16 +199,16 @@ require('render-markdown').setup({ signs = { '󰫎 ' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading icon and extends through the entire line - backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' }, + backgrounds = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { - '@markup.heading.1.markdown', - '@markup.heading.2.markdown', - '@markup.heading.3.markdown', - '@markup.heading.4.markdown', - '@markup.heading.5.markdown', - '@markup.heading.6.markdown', + 'RenderMarkdownH1', + 'RenderMarkdownH2', + 'RenderMarkdownH3', + 'RenderMarkdownH4', + 'RenderMarkdownH5', + 'RenderMarkdownH6', }, }, code = { @@ -233,7 +233,7 @@ require('render-markdown').setup({ -- Used below code blocks for thin border below = '▀', -- Highlight for code blocks & inline code - highlight = 'ColorColumn', + highlight = 'RenderMarkdownCode', }, dash = { -- Turn on / off thematic break rendering @@ -242,7 +242,7 @@ require('render-markdown').setup({ -- The icon gets repeated across the window's width icon = '─', -- Highlight for the whole line generated from the icon - highlight = 'LineNr', + highlight = 'RenderMarkdownDash', }, bullet = { -- Turn on / off list bullet rendering @@ -253,7 +253,7 @@ require('render-markdown').setup({ -- If the item is a 'checkbox' a conceal is used to hide the bullet instead icons = { '●', '○', '◆', '◇' }, -- Highlight for the bullet icon - highlight = 'Normal', + highlight = 'RenderMarkdownBullet', }, -- Checkboxes are a special instance of a 'list_item' that start with a 'shortcut_link' -- There are two special states for unchecked & checked defined in the markdown grammar @@ -264,13 +264,13 @@ require('render-markdown').setup({ -- Replaces '[ ]' of 'task_list_marker_unchecked' icon = '󰄱 ', -- Highlight for the unchecked icon - highlight = '@markup.list.unchecked', + highlight = 'RenderMarkdownUnchecked', }, checked = { -- Replaces '[x]' of 'task_list_marker_checked' icon = '󰱒 ', -- Highligh for the checked icon - highlight = '@markup.heading', + highlight = 'RenderMarkdownChecked', }, -- Define custom checkbox states, more involved as they are not part of the markdown grammar -- As a result this requires neovim >= 0.10.0 since it relies on 'inline' extmarks @@ -280,7 +280,7 @@ require('render-markdown').setup({ -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' icon custom = { - todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' }, + todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo' }, }, }, quote = { @@ -289,7 +289,7 @@ require('render-markdown').setup({ -- Replaces '>' of 'block_quote' icon = '▋', -- Highlight for the quote icon - highlight = '@markup.quote', + highlight = 'RenderMarkdownQuote', }, pipe_table = { -- Turn on / off pipe table rendering @@ -314,11 +314,11 @@ require('render-markdown').setup({ '│', '─', }, -- Highlight for table heading, delimiter, and the line above - head = '@markup.heading', + head = 'RenderMarkdownTableHead', -- Highlight for everything else, main table rows and the line below - row = 'Normal', + row = 'RenderMarkdownTableRow', -- Highlight for inline padding used to add back concealed space - filler = 'Conceal', + filler = 'RenderMarkdownTableFill', }, -- Callouts are a special instance of a 'block_quote' that start with a 'shortcut_link' -- Can specify as many additional values as you like following the pattern from any below, such as 'note' @@ -327,21 +327,21 @@ require('render-markdown').setup({ -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' text and quote markers callout = { - note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'DiagnosticInfo' }, - tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'DiagnosticOk' }, - important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'DiagnosticHint' }, - warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'DiagnosticWarn' }, - caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'DiagnosticError' }, + note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'RenderMarkdownInfo' }, + tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'RenderMarkdownSuccess' }, + important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'RenderMarkdownHint' }, + warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'RenderMarkdownWarn' }, + caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'RenderMarkdownError' }, -- Obsidian: https://help.a.md/Editing+and+formatting/Callouts - abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'DiagnosticInfo' }, - todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'DiagnosticInfo' }, - success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'DiagnosticOk' }, - question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'DiagnosticWarn' }, - failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'DiagnosticError' }, - danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'DiagnosticError' }, - bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'DiagnosticError' }, - example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'DiagnosticHint' }, - quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = '@markup.quote' }, + abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'RenderMarkdownInfo' }, + todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'RenderMarkdownInfo' }, + success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'RenderMarkdownSuccess' }, + question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'RenderMarkdownWarn' }, + failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'RenderMarkdownError' }, + danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'RenderMarkdownError' }, + bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'RenderMarkdownError' }, + example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'RenderMarkdownHint' }, + quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = 'RenderMarkdownQuote' }, }, link = { -- Turn on / off inline link icon rendering @@ -351,7 +351,7 @@ require('render-markdown').setup({ -- Inlined with 'inline_link' elements hyperlink = '󰌹 ', -- Applies to the inlined icon - highlight = '@markup.link.label.markdown_inline', + highlight = 'RenderMarkdownLink', }, sign = { -- Turn on / off sign rendering @@ -361,7 +361,7 @@ require('render-markdown').setup({ buftypes = { 'nofile' }, }, -- Applies to background of sign text - highlight = 'SignColumn', + highlight = 'RenderMarkdownSign', }, -- Window options to use that change between rendered and raw view win_options = { @@ -414,16 +414,16 @@ require('render-markdown').setup({ signs = { '󰫎 ' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading icon and extends through the entire line - backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' }, + backgrounds = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { - '@markup.heading.1.markdown', - '@markup.heading.2.markdown', - '@markup.heading.3.markdown', - '@markup.heading.4.markdown', - '@markup.heading.5.markdown', - '@markup.heading.6.markdown', + 'RenderMarkdownH1', + 'RenderMarkdownH2', + 'RenderMarkdownH3', + 'RenderMarkdownH4', + 'RenderMarkdownH5', + 'RenderMarkdownH6', }, }, }) @@ -455,7 +455,7 @@ require('render-markdown').setup({ -- Used below code blocks for thin border below = '▀', -- Highlight for code blocks & inline code - highlight = 'ColorColumn', + highlight = 'RenderMarkdownCode', }, }) ``` @@ -471,7 +471,7 @@ require('render-markdown').setup({ -- The icon gets repeated across the window's width icon = '─', -- Highlight for the whole line generated from the icon - highlight = 'LineNr', + highlight = 'RenderMarkdownDash', }, }) ``` @@ -489,7 +489,7 @@ require('render-markdown').setup({ -- If the item is a 'checkbox' a conceal is used to hide the bullet instead icons = { '●', '○', '◆', '◇' }, -- Highlight for the bullet icon - highlight = 'Normal', + highlight = 'RenderMarkdownBullet', }, }) ``` @@ -507,13 +507,13 @@ require('render-markdown').setup({ -- Replaces '[ ]' of 'task_list_marker_unchecked' icon = '󰄱 ', -- Highlight for the unchecked icon - highlight = '@markup.list.unchecked', + highlight = 'RenderMarkdownUnchecked', }, checked = { -- Replaces '[x]' of 'task_list_marker_checked' icon = '󰱒 ', -- Highligh for the checked icon - highlight = '@markup.heading', + highlight = 'RenderMarkdownChecked', }, -- Define custom checkbox states, more involved as they are not part of the markdown grammar -- As a result this requires neovim >= 0.10.0 since it relies on 'inline' extmarks @@ -523,7 +523,7 @@ require('render-markdown').setup({ -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' icon custom = { - todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' }, + todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo' }, }, }, }) @@ -539,7 +539,7 @@ require('render-markdown').setup({ -- Replaces '>' of 'block_quote' icon = '▋', -- Highlight for the quote icon - highlight = '@markup.quote', + highlight = 'RenderMarkdownQuote', }, }) ``` @@ -571,11 +571,11 @@ require('render-markdown').setup({ '│', '─', }, -- Highlight for table heading, delimiter, and the line above - head = '@markup.heading', + head = 'RenderMarkdownTableHead', -- Highlight for everything else, main table rows and the line below - row = 'Normal', + row = 'RenderMarkdownTableRow', -- Highlight for inline padding used to add back concealed space - filler = 'Conceal', + filler = 'RenderMarkdownTableFill', }, }) ``` @@ -591,21 +591,21 @@ require('render-markdown').setup({ -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' text and quote markers callout = { - note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'DiagnosticInfo' }, - tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'DiagnosticOk' }, - important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'DiagnosticHint' }, - warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'DiagnosticWarn' }, - caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'DiagnosticError' }, + note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'RenderMarkdownInfo' }, + tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'RenderMarkdownSuccess' }, + important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'RenderMarkdownHint' }, + warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'RenderMarkdownWarn' }, + caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'RenderMarkdownError' }, -- Obsidian: https://help.a.md/Editing+and+formatting/Callouts - abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'DiagnosticInfo' }, - todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'DiagnosticInfo' }, - success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'DiagnosticOk' }, - question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'DiagnosticWarn' }, - failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'DiagnosticError' }, - danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'DiagnosticError' }, - bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'DiagnosticError' }, - example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'DiagnosticHint' }, - quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = '@markup.quote' }, + abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'RenderMarkdownInfo' }, + todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'RenderMarkdownInfo' }, + success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'RenderMarkdownSuccess' }, + question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'RenderMarkdownWarn' }, + failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'RenderMarkdownError' }, + danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'RenderMarkdownError' }, + bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'RenderMarkdownError' }, + example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'RenderMarkdownHint' }, + quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = 'RenderMarkdownQuote' }, }, }) ``` @@ -622,7 +622,7 @@ require('render-markdown').setup({ -- Inlined with 'inline_link' elements hyperlink = '󰌹 ', -- Applies to the inlined icon - highlight = '@markup.link.label.markdown_inline', + highlight = 'RenderMarkdownLink', }, }) ``` @@ -639,11 +639,45 @@ require('render-markdown').setup({ buftypes = { 'nofile' }, }, -- Applies to background of sign text - highlight = 'SignColumn', + highlight = 'RenderMarkdownSign', }, }) ``` +# Colors + +The table below shows all the highlight groups with their default link + +| Highlight Group | Default Group | Description | +| ----------------------- | ---------------------------------- | ------------------------- | +| RenderMarkdownH1 | @markup.heading.1.markdown | H1 icons | +| RenderMarkdownH2 | @markup.heading.2.markdown | H2 icons | +| RenderMarkdownH3 | @markup.heading.3.markdown | H3 icons | +| RenderMarkdownH4 | @markup.heading.4.markdown | H4 icons | +| RenderMarkdownH5 | @markup.heading.5.markdown | H5 icons | +| RenderMarkdownH6 | @markup.heading.6.markdown | H6 icons | +| RenderMarkdownH1Bg | DiffAdd | H1 background line | +| RenderMarkdownH2Bg | DiffChange | H2 background line | +| RenderMarkdownH3Bg | DiffDelete | H3-H6 background line | +| RenderMarkdownCode | ColorColumn | Code block background | +| RenderMarkdownBullet | Normal | List item bullet points | +| RenderMarkdownQuote | @markup.quote | Block quote marker | +| RenderMarkdownDash | LineNr | Thematic break line | +| RenderMarkdownLink | @markup.link.label.markdown_inline | Image & hyperlink icons | +| RenderMarkdownSign | SignColumn | Sign column background | +| RenderMarkdownMath | @markup.math | LaTeX lines | +| RenderMarkdownUnchecked | @markup.list.unchecked | Unchecked checkbox | +| RenderMarkdownChecked | @markup.list.checked | Checked checkbox | +| RenderMarkdownTodo | @markup.raw | Todo custom checkbox | +| RenderMarkdownTableHead | @markup.heading | Pipe table heading rows | +| RenderMarkdownTableRow | Normal | Pipe table body rows | +| RenderMarkdownTableFill | Conceal | Pipe table inline padding | +| RenderMarkdownSuccess | DiagnosticOk | Success related callouts | +| RenderMarkdownInfo | DiagnosticInfo | Info related callouts | +| RenderMarkdownHint | DiagnosticHint | Hint related callouts | +| RenderMarkdownWarn | DiagnosticWarn | Warning related callouts | +| RenderMarkdownError | DiagnosticError | Error related callouts | + # Additional Info - [Limitations](doc/limitations.md): Known limitations of this plugin diff --git a/demo/box_dash_quote.gif b/demo/box_dash_quote.gif index 2a68c58..e86b3a0 100644 Binary files a/demo/box_dash_quote.gif and b/demo/box_dash_quote.gif differ diff --git a/demo/callout.gif b/demo/callout.gif index a7a05c3..c2501d3 100644 Binary files a/demo/callout.gif and b/demo/callout.gif differ diff --git a/demo/heading_code.gif b/demo/heading_code.gif index 1e67639..5847462 100644 Binary files a/demo/heading_code.gif and b/demo/heading_code.gif differ diff --git a/demo/latex.gif b/demo/latex.gif index a153453..565c459 100644 Binary files a/demo/latex.gif and b/demo/latex.gif differ diff --git a/demo/list_table.gif b/demo/list_table.gif index 6cc4342..db7ffa2 100644 Binary files a/demo/list_table.gif and b/demo/list_table.gif differ diff --git a/doc/render-markdown.txt b/doc/render-markdown.txt index 2f8382b..f29d70d 100644 --- a/doc/render-markdown.txt +++ b/doc/render-markdown.txt @@ -21,7 +21,8 @@ Table of Contents *render-markdown-table-of-contents* - Callouts |render-markdown-setup-callouts| - Links |render-markdown-setup-links| - Signs |render-markdown-setup-signs| -7. Additional Info |render-markdown-additional-info| +7. Colors |render-markdown-colors| +8. Additional Info |render-markdown-additional-info| ============================================================================== 1. markdown.nvim *render-markdown-markdown.nvim* @@ -218,7 +219,7 @@ Full Default Configuration ~ -- Executable used to convert latex formula to rendered unicode converter = 'latex2text', -- Highlight for LaTeX blocks - highlight = '@markup.math', + highlight = 'RenderMarkdownMath', }, heading = { -- Turn on / off heading icon & background rendering @@ -235,16 +236,16 @@ Full Default Configuration ~ signs = { '󰫎 ' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading icon and extends through the entire line - backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' }, + backgrounds = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { - '@markup.heading.1.markdown', - '@markup.heading.2.markdown', - '@markup.heading.3.markdown', - '@markup.heading.4.markdown', - '@markup.heading.5.markdown', - '@markup.heading.6.markdown', + 'RenderMarkdownH1', + 'RenderMarkdownH2', + 'RenderMarkdownH3', + 'RenderMarkdownH4', + 'RenderMarkdownH5', + 'RenderMarkdownH6', }, }, code = { @@ -269,7 +270,7 @@ Full Default Configuration ~ -- Used below code blocks for thin border below = '▀', -- Highlight for code blocks & inline code - highlight = 'ColorColumn', + highlight = 'RenderMarkdownCode', }, dash = { -- Turn on / off thematic break rendering @@ -278,7 +279,7 @@ Full Default Configuration ~ -- The icon gets repeated across the window's width icon = '─', -- Highlight for the whole line generated from the icon - highlight = 'LineNr', + highlight = 'RenderMarkdownDash', }, bullet = { -- Turn on / off list bullet rendering @@ -289,7 +290,7 @@ Full Default Configuration ~ -- If the item is a 'checkbox' a conceal is used to hide the bullet instead icons = { '●', '○', '◆', '◇' }, -- Highlight for the bullet icon - highlight = 'Normal', + highlight = 'RenderMarkdownBullet', }, -- Checkboxes are a special instance of a 'list_item' that start with a 'shortcut_link' -- There are two special states for unchecked & checked defined in the markdown grammar @@ -300,13 +301,13 @@ Full Default Configuration ~ -- Replaces '[ ]' of 'task_list_marker_unchecked' icon = '󰄱 ', -- Highlight for the unchecked icon - highlight = '@markup.list.unchecked', + highlight = 'RenderMarkdownUnchecked', }, checked = { -- Replaces '[x]' of 'task_list_marker_checked' icon = '󰱒 ', -- Highligh for the checked icon - highlight = '@markup.heading', + highlight = 'RenderMarkdownChecked', }, -- Define custom checkbox states, more involved as they are not part of the markdown grammar -- As a result this requires neovim >= 0.10.0 since it relies on 'inline' extmarks @@ -316,7 +317,7 @@ Full Default Configuration ~ -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' icon custom = { - todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' }, + todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo' }, }, }, quote = { @@ -325,7 +326,7 @@ Full Default Configuration ~ -- Replaces '>' of 'block_quote' icon = '▋', -- Highlight for the quote icon - highlight = '@markup.quote', + highlight = 'RenderMarkdownQuote', }, pipe_table = { -- Turn on / off pipe table rendering @@ -350,11 +351,11 @@ Full Default Configuration ~ '│', '─', }, -- Highlight for table heading, delimiter, and the line above - head = '@markup.heading', + head = 'RenderMarkdownTableHead', -- Highlight for everything else, main table rows and the line below - row = 'Normal', + row = 'RenderMarkdownTableRow', -- Highlight for inline padding used to add back concealed space - filler = 'Conceal', + filler = 'RenderMarkdownTableFill', }, -- Callouts are a special instance of a 'block_quote' that start with a 'shortcut_link' -- Can specify as many additional values as you like following the pattern from any below, such as 'note' @@ -363,21 +364,21 @@ Full Default Configuration ~ -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' text and quote markers callout = { - note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'DiagnosticInfo' }, - tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'DiagnosticOk' }, - important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'DiagnosticHint' }, - warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'DiagnosticWarn' }, - caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'DiagnosticError' }, + note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'RenderMarkdownInfo' }, + tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'RenderMarkdownSuccess' }, + important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'RenderMarkdownHint' }, + warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'RenderMarkdownWarn' }, + caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'RenderMarkdownError' }, -- Obsidian: https://help.a.md/Editing+and+formatting/Callouts - abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'DiagnosticInfo' }, - todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'DiagnosticInfo' }, - success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'DiagnosticOk' }, - question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'DiagnosticWarn' }, - failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'DiagnosticError' }, - danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'DiagnosticError' }, - bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'DiagnosticError' }, - example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'DiagnosticHint' }, - quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = '@markup.quote' }, + abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'RenderMarkdownInfo' }, + todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'RenderMarkdownInfo' }, + success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'RenderMarkdownSuccess' }, + question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'RenderMarkdownWarn' }, + failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'RenderMarkdownError' }, + danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'RenderMarkdownError' }, + bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'RenderMarkdownError' }, + example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'RenderMarkdownHint' }, + quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = 'RenderMarkdownQuote' }, }, link = { -- Turn on / off inline link icon rendering @@ -387,7 +388,7 @@ Full Default Configuration ~ -- Inlined with 'inline_link' elements hyperlink = '󰌹 ', -- Applies to the inlined icon - highlight = '@markup.link.label.markdown_inline', + highlight = 'RenderMarkdownLink', }, sign = { -- Turn on / off sign rendering @@ -397,7 +398,7 @@ Full Default Configuration ~ buftypes = { 'nofile' }, }, -- Applies to background of sign text - highlight = 'SignColumn', + highlight = 'RenderMarkdownSign', }, -- Window options to use that change between rendered and raw view win_options = { @@ -449,16 +450,16 @@ HEADINGS *render-markdown-setup-headings* signs = { '󰫎 ' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading icon and extends through the entire line - backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' }, + backgrounds = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { - '@markup.heading.1.markdown', - '@markup.heading.2.markdown', - '@markup.heading.3.markdown', - '@markup.heading.4.markdown', - '@markup.heading.5.markdown', - '@markup.heading.6.markdown', + 'RenderMarkdownH1', + 'RenderMarkdownH2', + 'RenderMarkdownH3', + 'RenderMarkdownH4', + 'RenderMarkdownH5', + 'RenderMarkdownH6', }, }, }) @@ -491,7 +492,7 @@ CODE BLOCKS *render-markdown-setup-code-blocks* -- Used below code blocks for thin border below = '▀', -- Highlight for code blocks & inline code - highlight = 'ColorColumn', + highlight = 'RenderMarkdownCode', }, }) < @@ -508,7 +509,7 @@ DASHED LINE *render-markdown-setup-dashed-line* -- The icon gets repeated across the window's width icon = '─', -- Highlight for the whole line generated from the icon - highlight = 'LineNr', + highlight = 'RenderMarkdownDash', }, }) < @@ -527,7 +528,7 @@ LIST BULLETS *render-markdown-setup-list-bullets* -- If the item is a 'checkbox' a conceal is used to hide the bullet instead icons = { '●', '○', '◆', '◇' }, -- Highlight for the bullet icon - highlight = 'Normal', + highlight = 'RenderMarkdownBullet', }, }) < @@ -546,13 +547,13 @@ CHECKBOXES *render-markdown-setup-checkboxes* -- Replaces '[ ]' of 'task_list_marker_unchecked' icon = '󰄱 ', -- Highlight for the unchecked icon - highlight = '@markup.list.unchecked', + highlight = 'RenderMarkdownUnchecked', }, checked = { -- Replaces '[x]' of 'task_list_marker_checked' icon = '󰱒 ', -- Highligh for the checked icon - highlight = '@markup.heading', + highlight = 'RenderMarkdownChecked', }, -- Define custom checkbox states, more involved as they are not part of the markdown grammar -- As a result this requires neovim >= 0.10.0 since it relies on 'inline' extmarks @@ -562,7 +563,7 @@ CHECKBOXES *render-markdown-setup-checkboxes* -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' icon custom = { - todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' }, + todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo' }, }, }, }) @@ -579,7 +580,7 @@ BLOCK QUOTES *render-markdown-setup-block-quotes* -- Replaces '>' of 'block_quote' icon = '▋', -- Highlight for the quote icon - highlight = '@markup.quote', + highlight = 'RenderMarkdownQuote', }, }) < @@ -612,11 +613,11 @@ TABLES *render-markdown-setup-tables* '│', '─', }, -- Highlight for table heading, delimiter, and the line above - head = '@markup.heading', + head = 'RenderMarkdownTableHead', -- Highlight for everything else, main table rows and the line below - row = 'Normal', + row = 'RenderMarkdownTableRow', -- Highlight for inline padding used to add back concealed space - filler = 'Conceal', + filler = 'RenderMarkdownTableFill', }, }) < @@ -633,21 +634,21 @@ CALLOUTS *render-markdown-setup-callouts* -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' text and quote markers callout = { - note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'DiagnosticInfo' }, - tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'DiagnosticOk' }, - important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'DiagnosticHint' }, - warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'DiagnosticWarn' }, - caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'DiagnosticError' }, + note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'RenderMarkdownInfo' }, + tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'RenderMarkdownSuccess' }, + important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'RenderMarkdownHint' }, + warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'RenderMarkdownWarn' }, + caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'RenderMarkdownError' }, -- Obsidian: https://help.a.md/Editing+and+formatting/Callouts - abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'DiagnosticInfo' }, - todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'DiagnosticInfo' }, - success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'DiagnosticOk' }, - question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'DiagnosticWarn' }, - failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'DiagnosticError' }, - danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'DiagnosticError' }, - bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'DiagnosticError' }, - example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'DiagnosticHint' }, - quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = '@markup.quote' }, + abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'RenderMarkdownInfo' }, + todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'RenderMarkdownInfo' }, + success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'RenderMarkdownSuccess' }, + question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'RenderMarkdownWarn' }, + failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'RenderMarkdownError' }, + danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'RenderMarkdownError' }, + bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'RenderMarkdownError' }, + example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'RenderMarkdownHint' }, + quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = 'RenderMarkdownQuote' }, }, }) < @@ -665,7 +666,7 @@ LINKS *render-markdown-setup-links* -- Inlined with 'inline_link' elements hyperlink = '󰌹 ', -- Applies to the inlined icon - highlight = '@markup.link.label.markdown_inline', + highlight = 'RenderMarkdownLink', }, }) < @@ -683,14 +684,85 @@ SIGNS *render-markdown-setup-signs* buftypes = { 'nofile' }, }, -- Applies to background of sign text - highlight = 'SignColumn', + highlight = 'RenderMarkdownSign', }, }) < ============================================================================== -7. Additional Info *render-markdown-additional-info* +7. Colors *render-markdown-colors* + +The table below shows all the highlight groups with their default link + + ------------------------------------------------------------------------------------ + Highlight Group Default Group Description + ------------------------- ------------------------------------ --------------------- + RenderMarkdownH1 @markup.heading.1.markdown H1 icons + + RenderMarkdownH2 @markup.heading.2.markdown H2 icons + + RenderMarkdownH3 @markup.heading.3.markdown H3 icons + + RenderMarkdownH4 @markup.heading.4.markdown H4 icons + + RenderMarkdownH5 @markup.heading.5.markdown H5 icons + + RenderMarkdownH6 @markup.heading.6.markdown H6 icons + + RenderMarkdownH1Bg DiffAdd H1 background line + + RenderMarkdownH2Bg DiffChange H2 background line + + RenderMarkdownH3Bg DiffDelete H3-H6 background line + + RenderMarkdownCode ColorColumn Code block background + + RenderMarkdownBullet Normal List item bullet + points + + RenderMarkdownQuote @markup.quote Block quote marker + + RenderMarkdownDash LineNr Thematic break line + + RenderMarkdownLink @markup.link.label.markdown_inline Image & hyperlink + icons + + RenderMarkdownSign SignColumn Sign column + background + + RenderMarkdownMath @markup.math LaTeX lines + + RenderMarkdownUnchecked @markup.list.unchecked Unchecked checkbox + + RenderMarkdownChecked @markup.list.checked Checked checkbox + + RenderMarkdownTodo @markup.raw Todo custom checkbox + + RenderMarkdownTableHead @markup.heading Pipe table heading + rows + + RenderMarkdownTableRow Normal Pipe table body rows + + RenderMarkdownTableFill Conceal Pipe table inline + padding + + RenderMarkdownSuccess DiagnosticOk Success related + callouts + + RenderMarkdownInfo DiagnosticInfo Info related callouts + + RenderMarkdownHint DiagnosticHint Hint related callouts + + RenderMarkdownWarn DiagnosticWarn Warning related + callouts + + RenderMarkdownError DiagnosticError Error related + callouts + ------------------------------------------------------------------------------------ + +============================================================================== +8. Additional Info *render-markdown-additional-info* - Limitations : Known limitations of this plugin - Custom Handlers : Allow users to integrate custom rendering diff --git a/lua/render-markdown/colors.lua b/lua/render-markdown/colors.lua index 1ddb24a..f69928f 100644 --- a/lua/render-markdown/colors.lua +++ b/lua/render-markdown/colors.lua @@ -9,11 +9,59 @@ local cache = { ---@class render.md.Colors local M = {} +---@private +---@type string +M.prefix = 'RenderMarkdown' + +-- stylua: ignore +---@private +---@type table +M.colors = { + -- Headings + H1 = '@markup.heading.1.markdown', + H2 = '@markup.heading.2.markdown', + H3 = '@markup.heading.3.markdown', + H4 = '@markup.heading.4.markdown', + H5 = '@markup.heading.5.markdown', + H6 = '@markup.heading.6.markdown', + H1Bg = 'DiffAdd', + H2Bg = 'DiffChange', + H3Bg = 'DiffDelete', + -- General + Code = 'ColorColumn', + Bullet = 'Normal', + Quote = '@markup.quote', + Dash = 'LineNr', + Link = '@markup.link.label.markdown_inline', + Sign = 'SignColumn', + Math = '@markup.math', + -- Checkboxes + Unchecked = '@markup.list.unchecked', + Checked = '@markup.list.checked', + Todo = '@markup.raw', + -- Pipe tables + TableHead = '@markup.heading', + TableRow = 'Normal', + TableFill = 'Conceal', + -- Callouts + Success = 'DiagnosticOk', + Info = 'DiagnosticInfo', + Hint = 'DiagnosticHint', + Warn = 'DiagnosticWarn', + Error = 'DiagnosticError', +} + +function M.setup() + for name, link in pairs(M.colors) do + vim.api.nvim_set_hl(0, M.prefix .. name, { link = link, default = true }) + end +end + ---@param foreground string ---@param background string ---@return string M.combine = function(foreground, background) - local name = string.format('RenderMd_%s_%s', foreground, background) + local name = string.format('%s_%s_%s', M.prefix, foreground, background) if not vim.tbl_contains(cache.highlights, name) then local fg = M.get_hl(foreground).fg local bg = M.get_hl(background).bg @@ -26,7 +74,7 @@ end ---@param highlight string ---@return string M.inverse = function(highlight) - local name = string.format('RenderMd_Inverse_%s', highlight) + local name = string.format('%s_Inverse_%s', M.prefix, highlight) if not vim.tbl_contains(cache.highlights, name) then local hl = M.get_hl(highlight) vim.api.nvim_set_hl(0, name, { fg = hl.bg, bg = hl.fg }) diff --git a/lua/render-markdown/init.lua b/lua/render-markdown/init.lua index a4752e2..9174c6d 100644 --- a/lua/render-markdown/init.lua +++ b/lua/render-markdown/init.lua @@ -1,3 +1,4 @@ +local colors = require('render-markdown.colors') local manager = require('render-markdown.manager') local state = require('render-markdown.state') @@ -193,7 +194,7 @@ M.default_config = { -- Executable used to convert latex formula to rendered unicode converter = 'latex2text', -- Highlight for LaTeX blocks - highlight = '@markup.math', + highlight = 'RenderMarkdownMath', }, heading = { -- Turn on / off heading icon & background rendering @@ -210,16 +211,16 @@ M.default_config = { signs = { '󰫎 ' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading icon and extends through the entire line - backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete' }, + backgrounds = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { - '@markup.heading.1.markdown', - '@markup.heading.2.markdown', - '@markup.heading.3.markdown', - '@markup.heading.4.markdown', - '@markup.heading.5.markdown', - '@markup.heading.6.markdown', + 'RenderMarkdownH1', + 'RenderMarkdownH2', + 'RenderMarkdownH3', + 'RenderMarkdownH4', + 'RenderMarkdownH5', + 'RenderMarkdownH6', }, }, code = { @@ -244,7 +245,7 @@ M.default_config = { -- Used below code blocks for thin border below = '▀', -- Highlight for code blocks & inline code - highlight = 'ColorColumn', + highlight = 'RenderMarkdownCode', }, dash = { -- Turn on / off thematic break rendering @@ -253,7 +254,7 @@ M.default_config = { -- The icon gets repeated across the window's width icon = '─', -- Highlight for the whole line generated from the icon - highlight = 'LineNr', + highlight = 'RenderMarkdownDash', }, bullet = { -- Turn on / off list bullet rendering @@ -264,7 +265,7 @@ M.default_config = { -- If the item is a 'checkbox' a conceal is used to hide the bullet instead icons = { '●', '○', '◆', '◇' }, -- Highlight for the bullet icon - highlight = 'Normal', + highlight = 'RenderMarkdownBullet', }, -- Checkboxes are a special instance of a 'list_item' that start with a 'shortcut_link' -- There are two special states for unchecked & checked defined in the markdown grammar @@ -275,13 +276,13 @@ M.default_config = { -- Replaces '[ ]' of 'task_list_marker_unchecked' icon = '󰄱 ', -- Highlight for the unchecked icon - highlight = '@markup.list.unchecked', + highlight = 'RenderMarkdownUnchecked', }, checked = { -- Replaces '[x]' of 'task_list_marker_checked' icon = '󰱒 ', -- Highligh for the checked icon - highlight = '@markup.heading', + highlight = 'RenderMarkdownChecked', }, -- Define custom checkbox states, more involved as they are not part of the markdown grammar -- As a result this requires neovim >= 0.10.0 since it relies on 'inline' extmarks @@ -291,7 +292,7 @@ M.default_config = { -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' icon custom = { - todo = { raw = '[-]', rendered = '󰥔 ', highlight = '@markup.raw' }, + todo = { raw = '[-]', rendered = '󰥔 ', highlight = 'RenderMarkdownTodo' }, }, }, quote = { @@ -300,7 +301,7 @@ M.default_config = { -- Replaces '>' of 'block_quote' icon = '▋', -- Highlight for the quote icon - highlight = '@markup.quote', + highlight = 'RenderMarkdownQuote', }, pipe_table = { -- Turn on / off pipe table rendering @@ -325,11 +326,11 @@ M.default_config = { '│', '─', }, -- Highlight for table heading, delimiter, and the line above - head = '@markup.heading', + head = 'RenderMarkdownTableHead', -- Highlight for everything else, main table rows and the line below - row = 'Normal', + row = 'RenderMarkdownTableRow', -- Highlight for inline padding used to add back concealed space - filler = 'Conceal', + filler = 'RenderMarkdownTableFill', }, -- Callouts are a special instance of a 'block_quote' that start with a 'shortcut_link' -- Can specify as many additional values as you like following the pattern from any below, such as 'note' @@ -338,21 +339,21 @@ M.default_config = { -- 'rendered': Replaces the 'raw' value when rendering -- 'highlight': Highlight for the 'rendered' text and quote markers callout = { - note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'DiagnosticInfo' }, - tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'DiagnosticOk' }, - important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'DiagnosticHint' }, - warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'DiagnosticWarn' }, - caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'DiagnosticError' }, + note = { raw = '[!NOTE]', rendered = '󰋽 Note', highlight = 'RenderMarkdownInfo' }, + tip = { raw = '[!TIP]', rendered = '󰌶 Tip', highlight = 'RenderMarkdownSuccess' }, + important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important', highlight = 'RenderMarkdownHint' }, + warning = { raw = '[!WARNING]', rendered = '󰀪 Warning', highlight = 'RenderMarkdownWarn' }, + caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution', highlight = 'RenderMarkdownError' }, -- Obsidian: https://help.a.md/Editing+and+formatting/Callouts - abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'DiagnosticInfo' }, - todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'DiagnosticInfo' }, - success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'DiagnosticOk' }, - question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'DiagnosticWarn' }, - failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'DiagnosticError' }, - danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'DiagnosticError' }, - bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'DiagnosticError' }, - example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'DiagnosticHint' }, - quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = '@markup.quote' }, + abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract', highlight = 'RenderMarkdownInfo' }, + todo = { raw = '[!TODO]', rendered = '󰗡 Todo', highlight = 'RenderMarkdownInfo' }, + success = { raw = '[!SUCCESS]', rendered = '󰄬 Success', highlight = 'RenderMarkdownSuccess' }, + question = { raw = '[!QUESTION]', rendered = '󰘥 Question', highlight = 'RenderMarkdownWarn' }, + failure = { raw = '[!FAILURE]', rendered = '󰅖 Failure', highlight = 'RenderMarkdownError' }, + danger = { raw = '[!DANGER]', rendered = '󱐌 Danger', highlight = 'RenderMarkdownError' }, + bug = { raw = '[!BUG]', rendered = '󰨰 Bug', highlight = 'RenderMarkdownError' }, + example = { raw = '[!EXAMPLE]', rendered = '󰉹 Example', highlight = 'RenderMarkdownHint' }, + quote = { raw = '[!QUOTE]', rendered = '󱆨 Quote', highlight = 'RenderMarkdownQuote' }, }, link = { -- Turn on / off inline link icon rendering @@ -362,7 +363,7 @@ M.default_config = { -- Inlined with 'inline_link' elements hyperlink = '󰌹 ', -- Applies to the inlined icon - highlight = '@markup.link.label.markdown_inline', + highlight = 'RenderMarkdownLink', }, sign = { -- Turn on / off sign rendering @@ -372,7 +373,7 @@ M.default_config = { buftypes = { 'nofile' }, }, -- Applies to background of sign text - highlight = 'SignColumn', + highlight = 'RenderMarkdownSign', }, -- Window options to use that change between rendered and raw view win_options = { @@ -407,6 +408,7 @@ function M.setup(opts) state.inline_link_query = vim.treesitter.query.parse('markdown_inline', state.config.inline_link_query) end) + colors.setup() manager.setup() vim.api.nvim_create_user_command('RenderMarkdown', M.command, { diff --git a/tests/box_dash_quote_spec.lua b/tests/box_dash_quote_spec.lua index d5e9f50..ed24853 100644 --- a/tests/box_dash_quote_spec.lua +++ b/tests/box_dash_quote_spec.lua @@ -11,24 +11,24 @@ async_tests.describe('box_dash_quote.md', function() vim.list_extend(expected, util.heading(0, 1)) -- Checkboxes - vim.list_extend(expected, util.checkbox(2, ' 󰄱 ', '@markup.list.unchecked', false)) - vim.list_extend(expected, util.checkbox(3, ' 󰱒 ', '@markup.heading', false)) - vim.list_extend(expected, util.checkbox(4, ' 󰥔 ', '@markup.raw', true)) + vim.list_extend(expected, util.checkbox(2, ' 󰄱 ', 'RenderMarkdownUnchecked', false)) + vim.list_extend(expected, util.checkbox(3, ' 󰱒 ', 'RenderMarkdownChecked', false)) + vim.list_extend(expected, util.checkbox(4, ' 󰥔 ', 'RenderMarkdownTodo', true)) -- Line break vim.list_extend(expected, { { row = { 6 }, col = { 0 }, - virt_text = { { string.rep('─', vim.opt.columns:get()), 'LineNr' } }, + virt_text = { { string.rep('─', vim.opt.columns:get()), 'RenderMarkdownDash' } }, virt_text_pos = 'overlay', }, }) -- Quote lines vim.list_extend(expected, { - util.quote(8, ' %s ', '@markup.quote'), - util.quote(9, ' %s ', '@markup.quote'), + util.quote(8, ' %s ', 'Quote'), + util.quote(9, ' %s ', 'Quote'), }) local actual = util.get_actual_marks() diff --git a/tests/callout_spec.lua b/tests/callout_spec.lua index 6af9300..043175f 100644 --- a/tests/callout_spec.lua +++ b/tests/callout_spec.lua @@ -11,7 +11,7 @@ local function callout(row, start_col, end_col, text, highlight) return { row = { row, row }, col = { start_col, end_col }, - virt_text = { { text, highlight } }, + virt_text = { { text, 'RenderMarkdown' .. highlight } }, virt_text_pos = 'overlay', } end @@ -20,11 +20,11 @@ async_tests.describe('callout.md', function() async_tests.it('default', function() util.setup('demo/callout.md') - local info = 'DiagnosticInfo' - local ok = 'DiagnosticOk' - local hint = 'DiagnosticHint' - local warn = 'DiagnosticWarn' - local error = 'DiagnosticError' + local info = 'Info' + local ok = 'Success' + local hint = 'Hint' + local warn = 'Warn' + local error = 'Error' local expected = {} diff --git a/tests/latex_spec.lua b/tests/latex_spec.lua index 0c1555a..befe589 100644 --- a/tests/latex_spec.lua +++ b/tests/latex_spec.lua @@ -4,6 +4,24 @@ local util = require('tests.util') local eq = assert.are.same +---@param start_row integer +---@param end_row integer +---@param start_col integer +---@param end_col integer +---@param lines string[] +---@return render.md.MarkInfo +local function latex(start_row, end_row, start_col, end_col, lines) + local virt_lines = vim.tbl_map(function(line) + return { { line, 'RenderMarkdownMath' } } + end, lines) + return { + row = { start_row, end_row }, + col = { start_col, end_col }, + virt_lines = virt_lines, + virt_lines_above = true, + } +end + async_tests.describe('latex.md', function() async_tests.it('default', function() stub.new(vim.fn, 'executable', function(expr) @@ -23,27 +41,12 @@ async_tests.describe('latex.md', function() local expected = {} - -- Heading vim.list_extend(expected, util.heading(0, 1)) - vim.list_extend(expected, { -- Inline - { - row = { 2, 2 }, - col = { 0, 21 }, - virt_lines = { { { '√(3x-1)+(1+x)^2', '@markup.math' } } }, - virt_lines_above = true, - }, + latex(2, 2, 0, 21, { '√(3x-1)+(1+x)^2' }), -- Block - { - row = { 4, 7 }, - col = { 0, 2 }, - virt_lines = { - { { 'f(x,y) = x + √(y)', '@markup.math' } }, - { { 'f(x,y) = √(y) + x^2/4y', '@markup.math' } }, - }, - virt_lines_above = true, - }, + latex(4, 7, 0, 2, { 'f(x,y) = x + √(y)', 'f(x,y) = √(y) + x^2/4y' }), }) local actual = util.get_actual_marks() diff --git a/tests/util.lua b/tests/util.lua index 2b454f0..dd95d6a 100644 --- a/tests/util.lua +++ b/tests/util.lua @@ -35,18 +35,27 @@ M.setup = function(file, opts) util.scheduler() end +---@private +---@type string +M.prefix = 'RenderMarkdown' + ---@param row integer ---@param level integer ---@return render.md.MarkInfo[] M.heading = function(row, level) local icons = { '󰲡 ', ' 󰲣 ', ' 󰲥 ', ' 󰲧 ', ' 󰲩 ', ' 󰲫 ' } - local foreground = string.format('@markup.heading.%d.markdown', level) - local backgrounds = { 'DiffAdd', 'DiffChange', 'DiffDelete', 'DiffDelete', 'DiffDelete', 'DiffDelete' } + local foreground = string.format('%sH%d', M.prefix, level) + local background + if level < 3 then + background = string.format('%sH%dBg', M.prefix, level) + else + background = string.format('%sH3Bg', M.prefix) + end local sign_mark = { row = { row, row }, col = { 0, level }, sign_text = '󰫎 ', - sign_hl_group = string.format('RenderMd_%s_SignColumn', foreground), + sign_hl_group = string.format('%s_%s_%sSign', M.prefix, foreground, M.prefix), } if row == 0 then return { sign_mark } @@ -55,14 +64,14 @@ M.heading = function(row, level) { row = { row, row }, col = { 0, level }, - virt_text = { { icons[level], { foreground, backgrounds[level] } } }, + virt_text = { { icons[level], { foreground, background } } }, virt_text_pos = 'overlay', }, sign_mark, { row = { row, row + 1 }, col = { 0, 0 }, - hl_group = backgrounds[level], + hl_group = background, hl_eol = true, }, } @@ -80,7 +89,7 @@ M.bullet = function(row, col, level, spaces) return { row = { row, row }, col = { col, col + spaces + 2 }, - virt_text = { { string.rep(' ', spaces) .. icons[level], 'Normal' } }, + virt_text = { { string.rep(' ', spaces) .. icons[level], M.prefix .. 'Bullet' } }, virt_text_pos = 'overlay', } end @@ -122,7 +131,7 @@ M.inline_code = function(row, start_col, end_col) row = { row, row }, col = { start_col, end_col }, hl_eol = false, - hl_group = 'ColorColumn', + hl_group = M.prefix .. 'Code', } end @@ -134,7 +143,7 @@ M.code_block = function(start_row, end_row) row = { start_row, end_row }, col = { 0, 0 }, hl_eol = true, - hl_group = 'ColorColumn', + hl_group = M.prefix .. 'Code', } end @@ -151,12 +160,12 @@ M.code_language = function(row, start_col, end_col, icon, name, highlight) row = { row, row }, col = { start_col, end_col }, sign_text = icon, - sign_hl_group = string.format('RenderMd_%s_SignColumn', highlight), + sign_hl_group = string.format('%s_%s_%sSign', M.prefix, highlight, M.prefix), }, { row = { row }, col = { start_col }, - virt_text = { { icon .. name, { highlight, 'ColorColumn' } } }, + virt_text = { { icon .. name, { highlight, M.prefix .. 'Code' } } }, virt_text_pos = 'inline', }, } @@ -168,7 +177,7 @@ M.code_below = function(row, col) return { row = { row }, col = { col }, - virt_text = { { string.rep('▀', vim.opt.columns:get()), 'RenderMd_Inverse_ColorColumn' } }, + virt_text = { { string.rep('▀', vim.opt.columns:get()), M.prefix .. '_Inverse_' .. M.prefix .. 'Code' } }, virt_text_pos = 'overlay', } end @@ -186,7 +195,7 @@ M.link = function(row, start_col, end_col, image) return { row = { row, row }, col = { start_col, end_col }, - virt_text = { { icon, '@markup.link.label.markdown_inline' } }, + virt_text = { { icon, M.prefix .. 'Link' } }, virt_text_pos = 'inline', } end @@ -200,7 +209,7 @@ M.quote = function(row, format, highlight) return { row = { row, row }, col = { 0, vim.fn.strdisplaywidth(quote) }, - virt_text = { { quote, highlight } }, + virt_text = { { quote, M.prefix .. highlight } }, virt_text_pos = 'overlay', } end @@ -210,14 +219,16 @@ end ---@param head boolean ---@return render.md.MarkInfo M.table_pipe = function(row, col, head) - local highlight = 'Normal' + local highlight if head then - highlight = '@markup.heading' + highlight = 'TableHead' + else + highlight = 'TableRow' end return { row = { row, row }, col = { col, col + 1 }, - virt_text = { { '│', highlight } }, + virt_text = { { '│', M.prefix .. highlight } }, virt_text_pos = 'overlay', } end @@ -230,7 +241,7 @@ M.table_padding = function(row, col, spaces) return { row = { row }, col = { col }, - virt_text = { { string.rep(' ', spaces), 'Conceal' } }, + virt_text = { { string.rep(' ', spaces), M.prefix .. 'TableFill' } }, virt_text_pos = 'inline', } end @@ -244,13 +255,13 @@ M.table_border = function(row, section, lengths) local highlight if section == 'above' then border = { '┌', '┬', '┐' } - highlight = '@markup.heading' + highlight = 'TableHead' elseif section == 'delimiter' then border = { '├', '┼', '┤' } - highlight = '@markup.heading' + highlight = 'TableHead' elseif section == 'below' then border = { '└', '┴', '┘' } - highlight = 'Normal' + highlight = 'TableRow' end local parts = vim.tbl_map(function(length) @@ -262,14 +273,14 @@ M.table_border = function(row, section, lengths) return { row = { row }, col = { 0 }, - virt_lines = { { { value, highlight } } }, + virt_lines = { { { value, M.prefix .. highlight } } }, virt_lines_above = section == 'above', } else return { row = { row, row }, col = { 0, vim.fn.strdisplaywidth(value) }, - virt_text = { { value, highlight } }, + virt_text = { { value, M.prefix .. highlight } }, virt_text_pos = 'overlay', } end @@ -281,14 +292,16 @@ end ---@param head boolean ---@return render.md.MarkInfo M.table_row = function(row, col, value, head) - local highlight = 'Normal' + local highlight if head then - highlight = '@markup.heading' + highlight = 'TableHead' + else + highlight = 'TableRow' end return { row = { row, row }, col = { 0, col }, - virt_text = { { value, highlight } }, + virt_text = { { value, M.prefix .. highlight } }, virt_text_pos = 'overlay', } end