This is my modified attempt derived from https://gist.github.com/galaxia4Eva/9e91c4f275554b4bd844b6feece16b3d with vim.defer_fn(setCursor, 10)
to make sure the terminal has time to process the content and the buffer is ready.
/home/YOUR_USER/.config/nvim/lua/kitty+page.lua:
return function(INPUT_LINE_NUMBER)
vim.opt.encoding='utf-8'
-- Prevent auto-centering on click
vim.opt.scrolloff = 0