MeanderingProgrammer / render-markdown.nvim

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

✨feat(`heading.background_eol`): New option added. #94

Closed Zeioth closed 3 months ago

Zeioth commented 3 months ago

The new option

heading = {
  background_eol = false
}

When set to false, it allow rendering the background until the end of the text, instead of until the end of the line:

screenshot_2024-07-24_21-24-52_639052097

Which again, it's really nice for people using vim.opt.colorcolumn.

Zeioth commented 3 months ago

It would be extra nice if we could specify width instead, but it seems this is not currently possible for [nvim_buf_set_extmark()](https://neovim.io/doc/user/api.html#nvim_buf_set_extmark()).

MeanderingProgrammer commented 3 months ago

It would be extra nice if we could specify width instead, but it seems this is not currently possible for [nvim_buf_set_extmark()](https://neovim.io/doc/user/api.html#nvim_buf_set_extmark()).

This is possible, but not directly via the vim API. Instead you would need to create 2 separate marks. One that highlights the text and another that starts after the text using virt_text_win_col and does an overlay with spaces to fill the remaining gap.

I think it makes sense to leave the door open for supporting a width or right_pad attribute in the future.

I don't think the background_eol argument would fit nicely with that. To keep some internal consistency can you follow the code configuration example and add a width field instead with values of full which would be for the current behavior & block for the new behavior.

Then the mark logic becomes: hl_eol = heading.width == 'full',.

Code block PR for reference: https://github.com/MeanderingProgrammer/markdown.nvim/pull/88.

In the future we can add something like right_pad but not necessary in this PR.

Zeioth commented 3 months ago

If you wanna take it from here it's ok. Otherwise I can come back to it in a few days.

MeanderingProgrammer commented 3 months ago

Cool, merged it here: https://github.com/MeanderingProgrammer/markdown.nvim/commit/426b13574c8264636e5660e5f5a3b4f5e3d5a937.

Mostly just the rename to heading.width instead of heading.background_eol.

Thanks for the PR!

MeanderingProgrammer commented 3 months ago

left_pad, right_pad, and min_width have all been added as options for headings: https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/6392a5dfa10f367e10fe58ea9c2faf3179b145d5