sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.87k stars 165 forks source link

Feature Request: add markdown headings background #212

Open luigir-it opened 1 month ago

luigir-it commented 1 month ago

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,
    }
  2. 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,
    })
antoineco commented 1 month ago

This looks nice indeed 👌

The use case of markdown headings is very specific, and this one applies to a specific plugin as well, so I guess it would be fine to use a blend of Gruvbox Material's foreground colors with the dimmed background color to obtain a pleasant effect.

The only thing that bothers me with making that change is that the colorscheme has multiple color variations. This would require quite a lot of off-palette colors to be included.