Closed expipiplus1 closed 1 month ago
hey 👋
haskell-tools just parses the response it receives from haskell-language-server, to create the hover actions. There's nothing that can be done in this plugin to solve your problem. hls might still be gathering information the first time you open the hover window, but will respond with partial hover information while doing so.
Looks like this: https://github.com/haskell/haskell-language-server/issues/3062 thanks
FWIW this is what I'm using now
["<Leader>lo"] = {
function()
local function make_hover_request(callback, retry)
local params = vim.lsp.util.make_position_params()
vim.lsp.buf_request(0, "textDocument/hover", params, function(err, result, _, _)
if err or not result or not result.contents then
if not retry then print "No hover information available" end
return
end
local markdown_lines = vim.lsp.util.convert_input_to_markdown_lines(result.contents)
local uri
for _, line in ipairs(markdown_lines) do
if vim.startswith(line, "[Documentation]") then
uri = string.match(line, "%[Documentation%]%((.+)%)")
if uri then
callback(uri)
return
end
end
end
if not retry then
-- If we didn't find the documentation link, try once more
vim.defer_fn(function() make_hover_request(callback, true) end, 100)
else
print "Could not find documentation link"
end
end)
end
make_hover_request(function(uri)
if uri then
vim.fn.jobstart({ "xdg-open", uri }, { detach = true })
print "Opening documentation in browser"
end
end)
end,
desc = "Open documentation",
cond = function(client) return client.supports_method "textDocument/hover" end,
},
Just in case anyone else wants this
@expipiplus1 I think you meant to post that in #395 :smile:
Neovim version (nvim -v)
v0.10.1
Operating system/version
NixOS
Output of :checkhealth haskell-tools
How to reproduce the issue
Load a haskell project and wait for hls to initialize
Open the hover menu on an identifier
vim.lsp.buf.hover()
or whatever keybinding existsObserve that the Open documentation in browser and Open source in browser links are not present
Close the menu
Open it again and observe that they're present
Expected behaviour
The first time the hover menu is opened these links are present (if available)
Actual behaviour
Sometimes, to see these links the hover must be closed and reopened
Log files
No response
The minimal config used to reproduce this issue.