MeanderingProgrammer / render-markdown.nvim

Plugin to improve viewing Markdown files in Neovim
MIT License
1.72k stars 38 forks source link

bug: Background color not working #118

Closed MusherM closed 3 months ago

MusherM commented 3 months ago

Neovim version (nvim -v)

0.10.1

Operating system

MacOS Sonoma

Terminal emulator / GUI

iTerm2

Describe the bug

I dont understand why mine looks so different from the look in the readme

截屏2024-08-05 22 11 09

Expected behavior

Heading with proper colors

Healthcheck output

============================================================================== render-markdown: require("render-markdown.health").check()

render-markdown.nvim [version] ~

render-markdown.nvim [configuration] ~

render-markdown.nvim [nvim-treesitter] ~

render-markdown.nvim [executables] ~

render-markdown.nvim [conflicts] ~

Plugin configuration

Installed with Lazy.nvim

return {
  "MeanderingProgrammer/render-markdown.nvim",
  opts = {},
  -- cmd = { "RenderMarkdown" },
  ft = { "markdown" },
  dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite
  -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
  -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
}

Confirmations

Additional information

No response

MeanderingProgrammer commented 3 months ago

This is up to the color scheme you use, the demos use https://github.com/folke/tokyonight.nvim.

The heading background highlight groups are RenderMarkdownH1Bg ... RenderMarkdownH6Bg, which if not directly supported by your color scheme default to DiffAdd, DiffChange, and DiffDelete. The values for those will determine the behavior and you can change them to whatever values you want with:

require('render-markdown').setup({
    heading = {
        backgrounds = {
            'Group1',
            'Group2',
            'Group3',
            'Group4',
            'Group5',
            'Group6',
        },
    },
})
MusherM commented 3 months ago

Thx for your reply! I'm now using NVChad and Lazy.nvim, as I type :highlight DiffChange, it give me something like DiffChange xxx guifg=#605f6f, and I guess that means this hight light group is provided.

I found similar problems with colors occuring when someone else using AutoSession with base46(color selector of NVChad), and I'm using another session manager, after disabling it, I got highlight background color with color code like #000, but the problem I mentioned remains unsolved.

Now I'm guessing it's related to the plugin loading order of Lazy.nvim or still related to my sessionManager plugin, I'm still digging out, I'd appreciate it if you can provide any advice!

MeanderingProgrammer commented 3 months ago

Ah the DiffChange in your case provides only guifg hence why there is no background. In my case it provides a guibg, which I thought was the more usual behavior. You'll need to manually provide / create some highlight groups with a background or use a different color scheme.

MusherM commented 3 months ago

Well that makes sense, I found no theme provides BG color in NVChad default themes, maybe that's intentional. I'll continue to dig out how to get a highlight group that matches my color theme. Really helps, thx a lot

MusherM commented 3 months ago

Well ,by adding this to chadrc.lua, I got the bg color, though I still find it not so well-looked like yours haha. Anyway, that helps!

M.base46 = {
  theme = "catppuccin",
  hl_override = {
    DiffAdd = {
      bg = "one_bg",
      fg = "orange",
    },
    DiffChange = {
      bg = "one_bg2",
      fg = "blue",
    },
    DiffDelete = {
      bg = "one_bg3",
      fg = "cyan",
    },
  },
}