Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lsp): redrawstatus on progress notifications #28569

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mfussenegger
Copy link
Member

@mfussenegger mfussenegger commented Apr 29, 2024

Problem:

Currently users can include vim.lsp.status() in their statusline, but
they won't see status changes if the statusline isn't redrawn on progress updates.

The simple solution for that is:

autocmd LspProgress * redrawstatus

But that has the problem that the last message remains stale until
something else triggers a redraw. To fix the stale messages, users would
have to add something like this:

local timer = vim.loop.new_timer()
api.nvim_create_autocmd("LspProgress", {
  group = lsp_group,
  callback = function()
    vim.cmd.redrawstatus()
    if timer then
      timer:stop()
      timer:start(500, 0, vim.schedule_wrap(function()
        timer:stop()
        vim.cmd.redrawstatus()
      end))
    end
  end
})

That's quite complex.

Solution:

Call redrawstatus by default. To avoid redrawstatus() burst the calls
are debounced to 60 FPS.

Problem:

Currently users can include `vim.lsp.status()` in their statusline, but
they won't see status changes without also adding a `LspProgress`
autocmd.

The simple solution for that is:

    autocmd LspProgress * redrawstatus

But that has the problem that the last message remains stale until
something else triggers a redraw. To fix the stale messages, users would
have to add something like this:

    local timer = vim.loop.new_timer()
    api.nvim_create_autocmd("LspProgress", {
      group = lsp_group,
      callback = function()
        vim.cmd.redrawstatus()
        if timer then
          timer:stop()
          timer:start(500, 0, vim.schedule_wrap(function()
            timer:stop()
            vim.cmd.redrawstatus()
          end))
        end
      end
    })

That's quite complex.

Solution:

Call redrawstatus by default. To avoid `redrawstatus()` burst the calls
are debounced to 60 FPS.
Copy link
Member

@justinmk justinmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a debounce util?

@gpanders gpanders added this to the 0.11 milestone May 6, 2024
@gpanders
Copy link
Member

gpanders commented May 6, 2024

Is redrawstatus "cheap" if the statusline hasn't changed? Otherwise, this could be wasteful if the user doesn't use LSP status messages in their statusline (unless we include that by default too?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants