Open modified register contents with gx

With coc I used to be able to open the http link that appears in the hover text (produced by haskell-language-server in this case) by editing it with :normal commands. But when I switched to the builtin client, it doesn’t work because the popup window is read-only. So I copy the text into a register but the keybinding doesn’t work:

vim.cmd([[
function! s:open_documentation()
        :lua vim.lsp.buf.hover()
        :wincmd w
        :normal G3k"dY
        :wincmd c
        :normal o
        :normal "dp0c2f/http://localhost:8000
        :normal 0gx
        :normal dd
endfunction
noremap <leader>M <SID>open_documentation()
]])

When I run it, I get the d register set correctly [Documentation](file:///home/aavogt/.ghcup/ghc/9.8.2/share/doc/ghc-9.8.2/html/libraries/process-1.6.18.0-9c1a/System-Process.html#v:createProcess), but I can’t figure out how to get gx to open the modified link http://localhost:8000/home/aavogt/.ghcup/ghc/9.8.2/share/doc/ghc-9.8.2/html/libraries/process-1.6.18.0-9c1a/System-Process.html#v:createProcess. It would be better to :new and :quit, but :new doesn’t do anything from the function.

I’m not sure if I’m talking about the same thing, but I use the builtin LSP diagnostics (+lspconfig plugin) and can focus the popups by pressing K a second time. I can’t remember where I saw this documented (if at all).

The relevant config stuff in my init.lua is set up using this function.

I get the cursor to jump into the other window with :wincmd w (default keybinding ) but as you say, a second call to vim.lsp.buf.hover() works too. My problem starts after that, where I want to change the hyperlink in the hover window slightly before opening it in web browser.

Ah I misunderstood. I think the gx mapping only works in normal or selection mode, not on register content. And instead of messing around with pasting into buffers, you could try using vim.ui.open, as is done in the implementation for the gx mapping (check do_open defined a few lines above).