fidget.nvim icon indicating copy to clipboard operation
fidget.nvim copied to clipboard

Empty vim.lsp.util.get_progress_messages()

Open lcrockett opened this issue 4 years ago • 1 comments

Issue description

For some reason whenever I enable this plugin (installed via packer, activated using require('fidget').setup() ), the contents of vim.lsp.util.get_progress_messages() are overwritten with permanent and persistent entries.

Issue detail

Currently i'm using a little helper configuration for my status line to show if a language servers is currently running and reporting progress, see below. This helper uses vim.lsp.util.get_progress_messages()[1] to determine if the first found LS is reporting any progress. If no LS is reporting any progress, vim.lsp.util.get_progress_messages() will report empty -> {}.

Whenever fidget.nvim is activated this API always reports a default and populated table when requesting current progress status lua print(vim.inspect(vim.lsp.util.get_progress_messages())), regardless if any LS is actually reporting progress.

I'm confused as to why utilizing the Neovim API changes it's output depending on the activation of fidget.nvim, especially because it breaks my currently used status line helper.

See below for different API outputs of lua print(vim.inspect(vim.lsp.util.get_progress_messages())).

Expected behaviour

I would expect the Neovim API to output consistent data, regardless of fidget.nvim being used. I'm not really sure where the issue lies and how fidget.nvim affects this behaviour. It is however clear that merely activating / de-activating fidget.nvim triggers this issue.

Any pointers would be greatly appreciated.

API output

fidget.nvim not activated + traversed multiple Lua buffers + No LS reporting progress

{}

fidget.nvim not activated + traversed 1 Lua buffer + LS currently reporting progress

{ {
    done = true,
    name = "null-ls",
    percentage = 50,
    progress = true,
    title = "diagnostics_on_open"
  }, {
    message = "0/375",
    name = "sumneko_lua",
    percentage = 0,
    progress = true,
    title = "Loading workspace"
  } }

fidget.nvim activated + traversed 3 Lua buffers + No LS reporting progress / LS currently reporting progress

{ {
    name = "sumneko_lua",
    progress = true,
    title = "empty title"
  }, {
    name = "sumneko_lua",
    progress = true,
    title = "empty title"
  }, {
    name = "sumneko_lua",
    progress = true,
    title = "empty title"
  } }

Helper configuration :: Current progres :: Status line

if vim.b.self_core_lsp_client_attached and #vim.tbl_keys(vim.lsp.buf_get_clients()) >= 1 then
  local lsp_client_name_first = vim.lsp.get_client_by_id(tonumber(vim.inspect(vim.tbl_keys(vim.lsp.buf_get_clients())):match('%d+'))).name:match('[%l%p]+')

  if lsp_client_name_first ~= nil then
    local lsp_progress_messages = vim.lsp.util.get_progress_messages()[1]

    if lsp_progress_messages then
      local lsp_progress_messages_ms = vim.loop.hrtime() / 1000000
      local lsp_progress_messages_percentage = lsp_progress_messages.percentage or 0
      local lsp_progress_messages_spinners = {
        "",
        "",
        "",
      }
      local lsp_progress_messages_frame = math.floor(lsp_progress_messages_ms / 120) % #lsp_progress_messages_spinners

      if lsp_progress_messages_percentage <= 70 then
        return lsp_progress_messages_spinners[lsp_progress_messages_frame + 1] .. ' '
      elseif lsp_progress_messages_percentage >= 70 then
        return ' '
      end
    end
  end
end

lcrockett avatar Feb 21 '22 00:02 lcrockett

Thanks for submitting this report! This is very interesting, and explains the output I was getting in #51.

To be honest, I'm just now learning about vim.lsp.util.get_progress_messages() (that it even existed, let alone what it is supposed to do). I'll get on this as soon as I clarify what that does/is supposed to do.

j-hui avatar Feb 21 '22 02:02 j-hui

Superseded by #130

j-hui avatar Jun 10 '23 07:06 j-hui