MeanderingProgrammer / render-markdown.nvim

Plugin to improve viewing Markdown files in Neovim
MIT License
1.39k stars 33 forks source link

Change color of Headings #48

Closed liston closed 2 months ago

liston commented 2 months ago

Not really an issue, but it is not obvious to me looking at the documentation on how to change the colors of h1, h2, h3 etc.

MeanderingProgrammer commented 2 months ago

Ah, I'll work on a better layout to explain what to edit to have what effect.

In this particular case you would provide highlights -> heading -> backgrounds / foregrounds.

The highlight for backgrounds is used for the line and foregrounds is used for the text.

The plugin indexes into the lists based on the level, so h4's get the 4th element. If you provide fewer elements we simply use the last one. So if you provide 3 elements we use the 3rd for an h4.

Hope that makes sense!

linkarzu commented 1 month ago
MeanderingProgrammer commented 1 month ago

Thank you :)

2 things:

  1. I'm a little lost on how you're getting the results in your video. Mostly in that some of your headings are full width, like the green and blue stretch across the entire window, and some of them end at the edge of the text. They should definitely be consistently one or the other, either all full width or all text width. It might be another plugin clashing, if you're using obsidian.nvim for example its own UI logic might be interfering here: https://github.com/MeanderingProgrammer/markdown.nvim?tab=readme-ov-file#obsidiannvim. I added some known clashing plugins to the healthcheck if you update and run checkhealth render-markdown it might help with that and likely other weird issues that will happen as a result.
  2. When you hover over a line all the virtual text and highlights added by my plugin go away, leaving you with the default view for that line. For headings tree-sitter will set the following highlight groups: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#markup. From there if you use a colorscheme it will most likely provide a value for these highlight group. But if you don't like it you can either try a different colorscheme or manually override the value for the various @markup.heading.n.markdown highlights in the same way you set them in the config: vim.cmd(string.format([[highlight @markup.heading.1.markdown cterm=bold gui=bold guifg=%s]], color_fg)), for example. You can run this command at any point in your config, so long is it is after your colorscheme loads.
linkarzu commented 1 month ago

markdown.nvim [neovim version] ~

markdown.nvim [configuration] ~

markdown.nvim [nvim-treesitter] ~

markdown.nvim [executables] ~

markdown.nvim [conflicts] ~

linkarzu com 2024-07-25 at 09 39 13