mrcjkb / haskell-tools.nvim

🦥 Supercharge your Haskell experience in neovim!
GNU General Public License v2.0
432 stars 18 forks source link

Reduce hover actions delay #327

Closed mizlan closed 6 months ago

mizlan commented 6 months ago

Feature description

There is a noticeable delay on hover (i.e., pressing K). Can it be made instantaneous?

mrcjkb commented 6 months ago

Hey 👋

By default, haskell-tools replaces the built-in hover handler with one that provides additional actions, like 'hoogle search for signature', etc.

Some of those actions require a request to haskell-language-server, to determine if they are possible. Those may be causing the delay for you. Currently, there is no way to disable only those hover actions. I will look into that when I have some time.

Until then, you can tell haskell-tools to use Neovim's builtin hover with the tools.hover.enable config (see :h haskell-tools.config).

mrcjkb commented 6 months ago

🤔 Come to think of it, maybe I can reduce the delay by sending multiple requests asynchronously and using coroutines to gather the responses.

mrcjkb commented 6 months ago

@mizlan do you have a GIF or an asciinema recording showing how severe the delay is for you? Is it always a noticeable delay, or just certain hovers (e.g. ones with lots of hover actions)?

mizlan commented 6 months ago

Sorry, the delay is not severe at all, under 200ms probably but definitely noticeable when coming from e.g. ocamllsp. There are just the normal hover actions like search with hoogle etc.

mrcjkb commented 6 months ago

Sorry, the delay is not severe at all, under 200ms probably but definitely noticeable when coming from e.g. ocamllsp. There are just the normal hover actions like search with hoogle etc.

🤔 How is it with vim.g.haskell_tools.tools.hover.enable set to false, using the built-in hover?

mizlan commented 6 months ago

Never mind, the delay must've been a one-off occurrence. It is speedy now and dissimilar to the other time I experienced it.

I also can't seem to disable it using that variable, but also I'm using Lazy which from what I read in your blogpost you are potentially not the biggest fan of

Config is here: https://github.com/mizlan/dotfiles/blob/0ecbc8e0f634b17f3c256ea99d95917ab3b4f06a/nvim/.config/nvim/init.lua#L401-L406

mrcjkb commented 6 months ago

Never mind, the delay must've been a one-off occurrence.

That probably means it's not easily reproducible 🤔 I'll close it for now. Feel free to reopen if you come across it again 😃

I also can't seem to disable it using that variable, but also I'm using Lazy which from what I read in your blogpost you are potentially not the biggest fan of

I don't use lazy.nvim personally, but I wouldn't say I'm not a fan. I'm just not a fan of the problem it tries to solve 😅

Ah, you're calling require('haskell-tools') (which causes the config to be initialised) before setting the config, so it doesn't get picked up.

You can change the signature of your on_attach function to

on_attach = function(_client, bufnr, ht)

and remove the require.

I should probably make the haskell-tools module lazy in its fields to prevent that.