Ale: Use CursorHold for LSP hover messages

Created on 26 Apr 2018  Â·  8Comments  Â·  Source: dense-analysis/ale

ALE now supports an :ALEHover command for displaying information at the cursor, but we can take this to the next level with the following changes.

  1. Re-use the truncated echo function from ale#cursor to implement a truncated echo message to avoid interrupting editing.
  2. Add support for calling the hover function so it will use the truncated echo.
  3. Add support for setting CursorHold to trigger the truncated echo version of :ALEHover, using the first line of output.
  4. Avoid replacing the messages about diagnostics ALE echoes, so problems take priority over basic information. (Detect if the feature is turned on.)

With the series of changes described above, it should be possible to create a version of hover messages where messages display when you move your cursor over things and actually "hover."

LSP enhancement

Most helpful comment

A longer-term feature that would be super cool: support neovim's floating windows (if/when they're merged), to show the hover messages right above the cursor!

All 8 comments

A longer-term feature that would be super cool: support neovim's floating windows (if/when they're merged), to show the hover messages right above the cursor!

Avoid replacing the messages about diagnostics ALE echoes, so problems take priority over basic information. (Detect if the feature is turned on.)

That’s not always desirable as one can use :ALEHover to fix the problem — the workflow I have when working with Merlin/OCaml — I go to the line with an error and query for types under the cursor to get the proper understanding of the problem.

If you want to see the message, you can type :ALEHover anyway. This would be in addition to that.

If you want to see the message, you can type :ALEHover anyway. This would be in addition to that.

Ok, I mistakenly thought this applies to :ALEHover too. It makes sense to me then, sorry for the noise.

I have a naive version of this at https://github.com/mlwarner/ale/commit/ecbf3a124656687f0950a03a5e6930327418868b but probably can't get to it until this weekend. Still needs

  1. To not override the diagnostic CursorHold
  2. Unit tests + refactoring to move the truncated message out of the cursor

otherwise it meets the first 3 points required

A longer-term feature that would be super cool: support neovim's floating windows (if/when they're merged), to show the hover messages right above the cursor!

it seems that this feature has been released :tada:

Will this ever be implemented? I have been looking to have similar behavior from Shougo/echodoc, and I saw that :ALEHover had that already, but only manually.

I have implemented this now at last. I tested it during my day job, and the messages are subtle enough that I turned the new g:ale_hover_cursor setting on by default.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trevordmiller picture trevordmiller  Â·  3Comments

kronos29296 picture kronos29296  Â·  4Comments

plexigras picture plexigras  Â·  3Comments

chauncey-garrett picture chauncey-garrett  Â·  3Comments

glepnir picture glepnir  Â·  3Comments