dense-analysis / dense-analysis/ale

ale_hover_cursor is not respected after ALE is initialized

Open
#4,832 2 comments 0 reactions 2 assignees Claimed by @Angelchev View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

## Information

**VIM version**

NVIM v0.10.1
Build type: Release

Operating System: Arch Linux 6.10.10-arch1-1

## What went wrong

**TL;DR: `g:ale_hover_cursor` is only checked when ALE is initializing. Setting this variable afterwards does not change ALE's behavior. Setting `g:ale_hover_cursor` in Lazy's `config` callback per ALE's README example does not work.**

I recently started trying [noice.nvim](https://github.com/folke/noice.nvim) and noticed that a window pops up when I move my cursor around:

![image_2024-09-17_13-08-51](https://github.com/user-attachments/assets/2cc5fa2e-e4e2-4c4a-a148-d0f0459cbb55)

After looking around and disabling different plugins like coc.nvim and others, I narrowed the issue down to ALE. After searching the internet and asking GPT, I tried adding these into my Nvim config, but they didn't help:

- `vim.g.ale_echo_cursor` = 0
- `vim.g.ale_hover_cursor` = 0
- `vim.g.ale_cursor_detail` = 0

So I turned on debug logging and started tracing the code to see where it came from. Here's the traced callstack:

- `cursor.vim : ale#cursor#Echom : 17`
- `cursor.vim : ale#cursor#TruncatedEcho : 41`
- `hover.vim : ale#hover#HandleLSPResponse : 250`
- `hover.vim : s:OnReady : 284`
- `hover.vim : ale#hover#Show : 335`
- `hover.vim : ale#hover#ShowTruncatedMessageAtCursor : 363`
- `events.vim : ale#events#Init : 218`

Specifically, after the initialization register the hover callback here on line 218 of `events.vim`:

https://github.com/dense-analysis/ale/blob/a7ef1817b7aa06d0f80952ad530be87ad3c8f6e2/autoload/ale/events.vim#L217-L219

... the `ale#hover#ShowTruncatedMessageAtCursor` function does not check for the `g:ale_hover_cursor` anymore:

https://github.com/dense-analysis/ale/blob/a7ef1817b7aa06d0f80952ad530be87ad3c8f6e2/autoload/ale/hover.vim#L350-L371

In other words, changing this variable after the callback is registered won't alter ALE's behavior. I am reporting this as a "bug" because this is not my expected behavior. In ALE's documentations, we can set variables in Lazy's `config` section:

https://github.com/dense-analysis/ale/blob/a7ef1817b7aa06d0f80952ad530be87ad3c8f6e2/README.md?plain=1#L296-L312

However, setting `vim.g.ale_hover_cursor` in the `config` callback function doesn't really work:

![image](https://github.com/user-attachments/assets/998b51d8-a041-4798-a8b2-f2f6151e54f5)

It has to be set before `require('lazy').setup()` is executed, so I think this is a bit counterintuitive. Perhaps it'll be better to add another check for the variable in `ale#hover#ShowTruncatedMessageAtCursor` or somewhere that makes it possible to change `ale_hover_cursor` on the fly without doing `ALEToggle` twice?

In the event this won't be fixed, for anyone that's having the same issue, just do `vim.g.ale_hover_cursor = 0` before `require('lazy').setup()` and it should be fine.

## Reproducing the bug

1. Install folke/noice.nvim
2. Install ALE
3. Open a file with LSP support and move the cursor onto a symbol. Notice how an `echom` command pops up.

### :ALEInfo

Expand


Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.