lukas-reineke / headlines.nvim

This plugin adds horizontal highlights for text filetypes, like markdown, orgmode, and neorg.
MIT License
699 stars 28 forks source link

fix: ensure fat headlines are not shifted by conflicting extmarks #70

Closed PriceHiller closed 8 months ago

PriceHiller commented 8 months ago

Copied from the body of the commit message:

This commit makes headlines.nvim compatible with Nvim Orgmode's new Virtual Indent option added by https://github.com/nvim-orgmode/orgmode/pull/627.

This also will ensure any features like it in the future from other plugins do not interfere with the headlines later on.

In theory, extmark priorities would work here, but in pratice they do not. If this extmark is set last by a higher priority using only the virtual text, it can be arbitrarily shifted by other extmark content and the same occurs when the extmark set is of a lower priority. By specifying the window column to apply to, we bypass all the priorities shenanigans and directly set the correct position of the headline.

TL;DR:

Adds compat with virtual indents in Nvim Orgmode.

Before this change: image Notice the weird indents on lines 2, 3, 5, 6, and 8. Those result from a conflicting extmark set by Nvim Orgmode trying to set virtual indentation.

After this change: image

Now headlines.nvim directly sets the window column to apply to instead of battling with other extmarks on virtext. (As a note, extmark priorities are not a solution in this case afaik, see the commit message body paragraph 3 for more details.)