From 6aa19e9bf36938049e36cd97aafedfe938de8d79 Mon Sep 17 00:00:00 2001 From: MeanderingProgrammer Date: Thu, 18 Jul 2024 20:58:33 -0700 Subject: [PATCH] feature: Add separate backgrounds for H3-H6 instead of sharing ## Details Requested: https://github.com/MeanderingProgrammer/markdown.nvim/issues/70 --- README.md | 23 ++++++++++++++++++++--- doc/render-markdown.txt | 26 +++++++++++++++++++++++--- lua/render-markdown/colors.lua | 3 +++ lua/render-markdown/init.lua | 9 ++++++++- tests/util.lua | 7 +------ 5 files changed, 55 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1c40840..44fdb33 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,14 @@ 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 = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, + backgrounds = { + 'RenderMarkdownH1Bg', + 'RenderMarkdownH2Bg', + 'RenderMarkdownH3Bg', + 'RenderMarkdownH4Bg', + 'RenderMarkdownH5Bg', + 'RenderMarkdownH6Bg', + }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { @@ -414,7 +421,14 @@ 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 = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, + backgrounds = { + 'RenderMarkdownH1Bg', + 'RenderMarkdownH2Bg', + 'RenderMarkdownH3Bg', + 'RenderMarkdownH4Bg', + 'RenderMarkdownH5Bg', + 'RenderMarkdownH6Bg', + }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { @@ -658,7 +672,10 @@ The table below shows all the highlight groups with their default link | RenderMarkdownH6 | @markup.heading.6.markdown | H6 icons | | RenderMarkdownH1Bg | DiffAdd | H1 background line | | RenderMarkdownH2Bg | DiffChange | H2 background line | -| RenderMarkdownH3Bg | DiffDelete | H3-H6 background line | +| RenderMarkdownH3Bg | DiffDelete | H3 background line | +| RenderMarkdownH4Bg | DiffDelete | H4 background line | +| RenderMarkdownH5Bg | DiffDelete | H5 background line | +| RenderMarkdownH6Bg | DiffDelete | H6 background line | | RenderMarkdownCode | ColorColumn | Code block background | | RenderMarkdownBullet | Normal | List item bullet points | | RenderMarkdownQuote | @markup.quote | Block quote marker | diff --git a/doc/render-markdown.txt b/doc/render-markdown.txt index 7cad8b2..2357a7e 100644 --- a/doc/render-markdown.txt +++ b/doc/render-markdown.txt @@ -239,7 +239,14 @@ 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 = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, + backgrounds = { + 'RenderMarkdownH1Bg', + 'RenderMarkdownH2Bg', + 'RenderMarkdownH3Bg', + 'RenderMarkdownH4Bg', + 'RenderMarkdownH5Bg', + 'RenderMarkdownH6Bg', + }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { @@ -453,7 +460,14 @@ 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 = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, + backgrounds = { + 'RenderMarkdownH1Bg', + 'RenderMarkdownH2Bg', + 'RenderMarkdownH3Bg', + 'RenderMarkdownH4Bg', + 'RenderMarkdownH5Bg', + 'RenderMarkdownH6Bg', + }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { @@ -717,7 +731,13 @@ The table below shows all the highlight groups with their default link RenderMarkdownH2Bg DiffChange H2 background line - RenderMarkdownH3Bg DiffDelete H3-H6 background line + RenderMarkdownH3Bg DiffDelete H3 background line + + RenderMarkdownH4Bg DiffDelete H4 background line + + RenderMarkdownH5Bg DiffDelete H5 background line + + RenderMarkdownH6Bg DiffDelete H6 background line RenderMarkdownCode ColorColumn Code block background diff --git a/lua/render-markdown/colors.lua b/lua/render-markdown/colors.lua index f69928f..dd90b6b 100644 --- a/lua/render-markdown/colors.lua +++ b/lua/render-markdown/colors.lua @@ -27,6 +27,9 @@ M.colors = { H1Bg = 'DiffAdd', H2Bg = 'DiffChange', H3Bg = 'DiffDelete', + H4Bg = 'DiffDelete', + H5Bg = 'DiffDelete', + H6Bg = 'DiffDelete', -- General Code = 'ColorColumn', Bullet = 'Normal', diff --git a/lua/render-markdown/init.lua b/lua/render-markdown/init.lua index 9174c6d..411d275 100644 --- a/lua/render-markdown/init.lua +++ b/lua/render-markdown/init.lua @@ -211,7 +211,14 @@ 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 = { 'RenderMarkdownH1Bg', 'RenderMarkdownH2Bg', 'RenderMarkdownH3Bg' }, + backgrounds = { + 'RenderMarkdownH1Bg', + 'RenderMarkdownH2Bg', + 'RenderMarkdownH3Bg', + 'RenderMarkdownH4Bg', + 'RenderMarkdownH5Bg', + 'RenderMarkdownH6Bg', + }, -- The 'level' is used to index into the array using a clamp -- Highlight for the heading and sign icons foregrounds = { diff --git a/tests/util.lua b/tests/util.lua index dd95d6a..b258826 100644 --- a/tests/util.lua +++ b/tests/util.lua @@ -45,12 +45,7 @@ M.prefix = 'RenderMarkdown' M.heading = function(row, level) local icons = { '󰲡 ', ' 󰲣 ', ' 󰲥 ', ' 󰲧 ', ' 󰲩 ', ' 󰲫 ' } 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 background = string.format('%sH%dBg', M.prefix, level) local sign_mark = { row = { row, row }, col = { 0, level },