obsidian.nvim icon indicating copy to clipboard operation
obsidian.nvim copied to clipboard

How to set header background color

Open dvogt23 opened this issue 6 months ago • 11 comments

Hey thanks for this great plugin 🙏🏾 is there a possibility to set background color for header like # ## ### ... ? Coudnt find the hl_groups.

Would like to have something like here: https://github.com/folke/todo-comments.nvim

thanks :)

dvogt23 avatar Feb 14 '24 21:02 dvogt23

I would like to know too! #392

peperonnii avatar Feb 15 '24 15:02 peperonnii

Figured it out after like a week...

You can use :Inspect to return the highlight of a specific element under your cursor. This way you can add custom highlights using vim.cmd[[highlight...]]

Would have been nice if someone pointed that out to me. But hope it helps.

peperonnii avatar Feb 22 '24 10:02 peperonnii

Thanks for now :))

Just getting this from Inspect:

Treesitter
  - @markup.heading.2.marker.markdown links to Title markdown

any idea, how to set colors for this?

dvogt23 avatar Feb 22 '24 10:02 dvogt23

yeah as i said you add a vim command to your lua config

vim.cmd[[highlight elementName guifg="#FFFFFF" guibg="#FF0000" gui=underline]]

you can specify fg color, bg color, and display type like bold italic, etc

your cursor is over the marker for ## not the h2 element itself

for changing the marker, its vim.cmd[[highlight @markup.heading.2.marker.markdown guifg="" ]]

peperonnii avatar Feb 22 '24 11:02 peperonnii

Great, it works. But now Im able to colorize marker and heading, not space between 😆 any idea how to get the whole line?

dvogt23 avatar Feb 22 '24 11:02 dvogt23

no highlight for the space in between, as far as im aware, shouldnt matter too much...

use google and these commands if confused about highlights. :highlights :Inspect :InspectTree

this type of stuff should be documented somewhere in the plugin, if the creator sees it, them im happy to make an entry into docs.

peperonnii avatar Feb 22 '24 11:02 peperonnii

this is what it looks like for me image

peperonnii avatar Feb 22 '24 11:02 peperonnii

You can use headlines.nvim to tweak the way your headlines look quite a bit. This goes much further than just adjusting the background color.

Here I assigned custom colors to different headline levels:

image

sotte avatar Mar 04 '24 14:03 sotte

Thats pretty cool! Thanks. Im gonna check that out.

peperonnii avatar Mar 04 '24 15:03 peperonnii

thanks, but dont like it. Looks to chaotic to me ... just wanna highlight marker of headings like

vim.cmd([[highlight @markup.heading.1.marker.markdown guibg=#FF5733 guifg=#FF5733]])
vim.cmd([[highlight @markup.heading.2.marker.markdown guibg=#C70039 guifg=#C70039]])
vim.cmd([[highlight @markup.heading.3.marker.markdown guibg=#900C3F guifg=#900C3F]])
vim.cmd([[highlight @markup.heading.4.marker.markdown guibg=#FFC300 guifg=#FFC300]])

and it worked like charm some weeks before ... now there is no @markup.heading.4.marker anymore :'(((

dvogt23 avatar Mar 04 '24 15:03 dvogt23

tbh ive never used past headings 2s...

Youre probably better off using headlines.nvim

peperonnii avatar Mar 04 '24 15:03 peperonnii