Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change code and quote line colors #77

Closed
jeremija opened this issue Jul 20, 2024 · 5 comments · Fixed by #81
Closed

Change code and quote line colors #77

jeremija opened this issue Jul 20, 2024 · 5 comments · Fixed by #81
Labels
enhancement New feature or request

Comments

@jeremija
Copy link
Contributor

jeremija commented Jul 20, 2024

Is your feature request related to a problem? Please describe.

I'd like to change the color of the concealed line used for the code blocks, as well as the > replacement character in blockquotes.

Describe the solution you'd like

A designated highlight group for changing the block character for code blocks.

Describe alternatives you've considered

Not really a Neovim theming expert, but I noticed that the color changes with different ctermfg/ctermbg values set in hi Normal. Haven't figured out how to change the color of the quote blocks yet. Setting RenderMarkdownCode highlight only seems to affect the rendering of actual code; it also disables treesitter's syntax highlighting when set.

Additional information

No response

@jeremija jeremija added the enhancement New feature or request label Jul 20, 2024
@jeremija
Copy link
Contributor Author

jeremija commented Jul 20, 2024

image

I'd like to make these horizontal and vertical lines darker if possible

@jeremija jeremija changed the title Change line colors Change code and quote line colors Jul 20, 2024
@jeremija
Copy link
Contributor Author

jeremija commented Jul 21, 2024

I believe the issue is somehow related to set notermguicolors, which I use in my theme config.

The vertical line can for the blockquote can be configured using hi RenderMarkdownInfo ..., I didn't realize that the [!NOTE] had special meaning.

@jeremija
Copy link
Contributor Author

jeremija commented Jul 21, 2024

Hmm, looks like the color.inverse only works with guicolors:

hi RenderMarkdownCode ctermbg=233 guibg=#333333

The hl.bg is set to nil when I have set notermguicolors enabled, but prints a value when I comment out set notermguicolors.

I suppose you'd need to invert the cterm values too, but the weird thing is that hl.cterm property is set to nil 🤔

@jeremija
Copy link
Contributor Author

jeremija commented Jul 21, 2024

I finally figured it out, this patch is needed to respect the color scheme when notermguicolors is set:

diff --git a/lua/render-markdown/colors.lua b/lua/render-markdown/colors.lua
index dd90b6b..7de03f2 100644
--- a/lua/render-markdown/colors.lua
+++ b/lua/render-markdown/colors.lua
@@ -80,7 +80,12 @@ M.inverse = function(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 })
+        vim.api.nvim_set_hl(0, name, {
+            fg = hl.bg,
+            bg = hl.fg,
+            ctermbg = hl.ctermfg,
+            ctermfg = hl.ctermbg,
+        })
         table.insert(cache.highlights, name)
     end
     return name

@jeremija
Copy link
Contributor Author

jeremija commented Jul 21, 2024

And it looks like there's a bug in lua type definitions in neovim API:

--- @class vim.api.keyset.hl_info.cterm : vim.api.keyset.hl_info.base
--- @field ctermfg? integer
--- @field ctermbg? integer
--- @field foreground? integer
--- @field background? integer

--- @class vim.api.keyset.hl_info : vim.api.keyset.hl_info.base
--- @field fg? integer
--- @field bg? integer
--- @field sp? integer
--- @field default? true
--- @field link? string
--- @field blend? integer
--- @field cterm? vim.api.keyset.hl_info.cterm

The cterm field is always nil, but ctermfg and ctermbg are present when defined.

Opened a bug neovim/neovim#29815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant