[TRACKER] hyperlink highlighting w/ mouse
chipsenkbeil opened this issue · 2 comments
chipsenkbeil commented
- Requires enabling
vim.opt.mousemoveevent = true
, which is off by default. - Sets a buffer-level keymap in normal mode for
<MouseMove>
. - Uses
vim.fn.getmousepos()
to give us a position within a window, which we then translate to figure out if we're over a link. - For 3, we need a
org-roam.utils.link_under_cursor
function to give us a link object.
From piemenu/example.lua:
vim.api.nvim_create_autocmd({ "FileType" }, {
group = group,
pattern = { "piemenu" },
callback = function()
vim.o.mousemoveevent = true
vim.keymap.set("n", "<MouseMove>", [[<Cmd>lua require("piemenu").highlight()<CR>]], { buffer = true })
vim.keymap.set("n", "<LeftDrag>", [[<Cmd>lua require("piemenu").highlight()<CR>]], { buffer = true })
vim.keymap.set("n", "<LeftRelease>", [[<Cmd>lua require("piemenu").finish()<CR>]], { buffer = true })
vim.keymap.set("n", "<RightMouse>", [[<Cmd>lua require("piemenu").cancel()<CR>]], { buffer = true })
end,
})
chipsenkbeil commented
An issue I found is that the mousemove event only triggers when the buffer is in focus. I'm wondering if this needs to be a global autocmd and then we detect which buffer we're over.
chipsenkbeil commented
Resolved by #10 where it seems that attaching to buffers for keymappings does work for mouse despite buffers being unfocused. It also added a lot more custom logic to handle detecting when the mouse is over the concealed text and not the raw text.