I find a way to mimic the mouse event to show the folded code. I write an autocmd this way :
local function on_mouse_hover()
local winid = require("ufo").peekFoldedLinesUnderCursor()
if not winid then
vim.lsp.buf.hover()
end
end
vim.api.nvim_create_autocmd("cursorHold", {
pattern = "*",
callback = on_mouse_hover,
desc = "Action sur hover du curseur - vois le code repliƩ",
})enter code here
When you click the mouse on a folded block it will show you the preview. For that to work you need first to setup the plugin nvim-ufo.
If you dont click the mouse then it will show you the LSP documentation for the word under the mouse pointer. I use the plugin "eagle-nvim" for that.