OXY2DEV/markview.nvim

๐Ÿž Bug: width of highlights.

Opened this issue ยท 8 comments

Before reporting:

  • Ensure that the issue is reproducable on the main branch.
  • Ensure that there isn't an issue on this(either open or closed).

Problem:

The rendering length of highlights and of replacements should respect window width. I believe currently it consider the width of the editor.

Steps to reproduce the issue:

Open a markdown file with a heading and a --- line separator in it.
Open a vertical split.

Now you will see the separator cut off as if it's rendering outside the viewport.

Expected behavior:

The rendering should occur within the bounds of the window width.

Neovim version:

NVIM v0.11.0-dev-ab98c5b Build type: Release LuaJIT 2.1.1727870382 Run "nvim -V1 -v" for more info

Hi,
what about replacing this highlighted line
image
for this
image

in both left and right portions?

This is before
image
And this is after
image

Nevermind, it doesn't work when there are multiple horizontal and veritcal windows, i'll see if i can fix it right

Hi.
So... if i understand how the plugin works, the rendering occurs per buffer.
So the image above works because both windows are the same width
However in this case
image
It doesn't work.
Right now the only thing that i can think of is rendering the buffer per window, but i don't know if the plugin is capable of that and i'm not sure if it's a good idea.

So for now im gonna leave this,
If someone knows better how the plugin works or has an idea please let me know. i'd be glad to listen :)

@viceav Buffers are like ๐Ÿ“ฆ, if 3 people looked at the contents of the ๐Ÿ“ฆ they will all see the same thing.

That's exactly what's happening.

Extmarks are local to the buffer. So, different windows can't show different things.

I think that is fine, but the highlight should consider the width based on the width largest window that the buffer is displayed in. Someone looking at the same buffer in differently sized windows is going to be a very very low probability event.

@OXY2DEV Got it, thanks for the explanation ๐Ÿ˜„

@Chaitanyabsprip what about adding this to your config?

repeat_amount = function(buffer) --[[@as function]]
	local windows = require("markview.utils").find_attached_wins(buffer)
	local textoff = vim.fn.getwininfo(vim.api.nvim_get_current_win())[1].textoff

	local max_width = 0
	for _, window in ipairs(windows) do
		max_width = math.max(max_width, vim.api.nvim_win_get_width(window))
	end
	return math.floor((max_width - textoff - 3) / 2)
end

๐Ÿค– Bot: Issue has not seen activity in 30 days and will therefore be marked as stale. It will be closed in 7 days if no further response is found.