Stuck in 'Loading...' for some elements randomly
Hi,
Sometimes, it keeps showing "Loading..." and I've had to restart the LSP using LspRestart until it starts working again and sometimes it doesn't. I'm not sure where to find the logs for further investigation.
Any suggestions on how to resolve this?
When I run vim.lsp.buf.references it shows some references. I mean the code works file.
My config: Nvim: v0.9.5
local SymbolKind = vim.lsp.protocol.SymbolKind
local function h(name)
return vim.api.nvim_get_hl(0, { name = name })
end
local function text_format(symbol)
local res = {}
-- Indicator that shows if there are any other symbols in the same line
local stacked_functions_content = symbol.stacked_count > 0 and ("+%s"):format(symbol.stacked_count) or ""
if symbol.references then
local usage = symbol.references <= 1 and "usage" or "usages"
local num = symbol.references == 0 and "no" or symbol.references
table.insert(res, { " ", "SymbolUsageRef" })
table.insert(res, { ("%s %s"):format(num, usage), "SymbolUsageContent" })
end
if symbol.definition then
if #res > 0 then
table.insert(res, { " ", "NonText" })
end
table.insert(res, { " ", "SymbolUsageDef" })
table.insert(res, { symbol.definition .. " defs", "SymbolUsageContent" })
end
if symbol.implementation then
if #res > 0 then
table.insert(res, { " ", "NonText" })
end
table.insert(res, { " ", "SymbolUsageImpl" })
table.insert(res, { symbol.implementation .. " impls", "SymbolUsageContent" })
end
if stacked_functions_content ~= "" then
if #res > 0 then
table.insert(res, { " ", "NonText" })
end
table.insert(res, { " ", "SymbolUsageImpl" })
table.insert(res, { stacked_functions_content, "SymbolUsageContent" })
end
return res
end
require("symbol-usage").setup({
kinds = {
SymbolKind.Function,
SymbolKind.Method,
SymbolKind.Struct,
SymbolKind.Interface,
SymbolKind.Class,
},
references = {
enabled = true,
include_declaration = false,
},
implementation = {
enabled = true,
},
vt_position = "end_of_line",
text_format = text_format,
})
This can happen because the server returned an error during one of the requests. For now, these errors are intentionally silent, but I plan to fix this behavior in the future.
Try using :lua require('symbol-usage').refresh() instead of :LspRestart, it should help.
same problem. it has been the same since #24 and #56 didn't help. when renaming ende to end using :lua vim.lsp.buf.rename() in the file provided below, there is an additional permanent inscription "loading..." above function a(). function b() is fine. and indeed, perhaps your assumption about errors is correct, because such renaming causes an error. however, when I tried to make a minimal config for the new issue, I found out that this does not occur on the minimal config. i dare to assume that the problem is in compatibility of plugin with some other one.
local M = {}
M.a = function()
local ende = "a"
print(ende)
end
M.b = function()
end
return M
as expected, :lua require('symbol-usage').refresh() helps to get rid of the problem, but alas, I would hate to have to restart the plugin after each renaming.
an addition to the comment above:
cfg.lua (test config I've used):
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
{
'Wansmer/symbol-usage.nvim',
event = 'BufReadPre',
config = function()
require('symbol-usage').setup({})
end
}
})
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = { "lua_ls" },
})
require("lspconfig").lua_ls.setup({})
i dare to assume that the problem is in compatibility of plugin with some other one.
I was able to reproduce the infinite Loading... on your example using my basic config. I think you are right - some 3rd party plugin is responsible for this.
It seems to stop all requests to the server when an error occurs (in this case, it's using the keyword end as a variable name).