From b09ef8705e360c73ff18a9d91290ec8cdd6e540c Mon Sep 17 00:00:00 2001 From: glepnir Date: Mon, 6 May 2024 19:12:06 +0800 Subject: [PATCH] only render visible part of screen --- lua/indentmini/init.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/indentmini/init.lua b/lua/indentmini/init.lua index c721324..a4a05c8 100644 --- a/lua/indentmini/init.lua +++ b/lua/indentmini/init.lua @@ -117,6 +117,11 @@ local function on_line(_, _, bufnr, row) if erow < 1 then return end + -- only render visible part of screen + local toprow = vim.fn.line('w0') - 2 + local botrow = vim.fn.line('w$') - 1 + srow = math.max(math.max(toprow, srow), 0) + erow = math.max(math.min(botrow, erow), api.nvim_buf_line_count(data.buf) - 1) local level = math.floor(curindent / shiftw) for i = srow + 1, erow, 1 do api.nvim_set_hl(