Skip to content

Feature Request: add markdown headings background #212

Open
@luigir-it

Description

Hi.
I'm using Neovim 0.10 with markdown.nvim

Right now, headers foreground look really nice (I guess thanks to #196), but we can't say the same thing for the background
The highlight groups for the background H{1..6} link respectively to:
DiffAdd
DiffChange
DiffDelete (3 to 6)
And look like this:
2024-07-28T14:59:04,409223905+02:00

I asked ChatGpt to make background colors that mix nicely with the foreground, and this is the result:
2024-07-28T15:49:41,404695863+02:00
Much nicer!

The lua functions I used to make this happen (I'm using LazyVim distribution):

  1. Define colors
{
    "sainnhe/gruvbox-material",
    init = function()
      vim.g.gruvbox_material_colors_override = {
        markbg1 = { "#2e1a1a", "52" }, -- Adjusted color code for #2e1a1a
        markbg2 = { "#332616", "94" }, -- Adjusted color code for #332616
        markbg3 = { "#3a3020", "100" }, -- Adjusted color code for #3a3020
        markbg4 = { "#243218", "22" }, -- Adjusted color code for #243218
        markbg5 = { "#1b2926", "23" }, -- Adjusted color code for #1b2926
        markbg6 = { "#2e1a20", "52" }, -- Adjusted color code for #2e1a20
      }
    end,
}
  1. Define highlight groups
vim.api.nvim_create_autocmd("ColorScheme", {
  group = vim.api.nvim_create_augroup("custom_highlights_gruvboxmaterial", {}),
  pattern = "gruvbox-material",
  callback = function()
    local config = vim.fn["gruvbox_material#get_configuration"]()
    local palette = vim.fn["gruvbox_material#get_palette"](config.background, config.foreground, config.colors_override)
    local set_hl = vim.fn["gruvbox_material#highlight"]
    set_hl("RenderMarkdownH1Bg", palette.none, palette.markbg1)
    set_hl("RenderMarkdownH2Bg", palette.none, palette.markbg2)
    set_hl("RenderMarkdownH3Bg", palette.none, palette.markbg3)
    set_hl("RenderMarkdownH4Bg", palette.none, palette.markbg4)
    set_hl("RenderMarkdownH5Bg", palette.none, palette.markbg5)
    set_hl("RenderMarkdownH6Bg", palette.none, palette.markbg6)
  end,
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions