From 4416ee8c2de57f9e22be87a345569f72099b697b Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sat, 24 Feb 2024 03:01:22 -0600 Subject: [PATCH] fix: ensure fat headlines are not shifted by conflicting extmarks 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. --- lua/headlines/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/headlines/init.lua b/lua/headlines/init.lua index 8bc5025..71dbc46 100644 --- a/lua/headlines/init.lua +++ b/lua/headlines/init.lua @@ -303,6 +303,7 @@ M.refresh = function() nvim_buf_set_extmark(bufnr, M.namespace, start_row - 1, 0, { virt_text = padding_above, virt_text_pos = "overlay", + virt_text_win_col = 0, hl_mode = "combine", }) else @@ -319,6 +320,7 @@ M.refresh = function() nvim_buf_set_extmark(bufnr, M.namespace, start_row + 1, 0, { virt_text = padding_below, virt_text_pos = "overlay", + virt_text_win_col = 0, hl_mode = "combine", }) last_fat_headline = start_row + 1