iTranslated by AI
Why snacks.nvim's LSP symbols were slow
Premise: snack.nvim's lsp_symbols() display is slow
There is an nvim plugin called snacks.nvim, which is like a convenient set of tools. I encountered an issue where the picker launched by the appropriately named lsp_symbols() function was abnormally slow (whereas it opens instantly in tools like telescope, so it is not an issue with the project size or the LSP itself).
Additionally, when I executed :lua Snacks.picker.lsp_symbols() directly, it operated at a normal speed, which revealed that the problem lay in the trigger from the keybind.
I consulted Gemini on this, and it suggested the following potential cause.
The cause is Leader + ss
-- Symbols for the current buffer only
{ "<Leader>s", function() Snacks.picker.lsp_symbols() end, desc = "LSP Symbols" },
-- LSP symbols for the entire workspace
{
"<Leader>ss",
function() Snacks.picker.lsp_workspace_symbols() end,
desc = "LSP Workspace Symbols",
},
By default, Neovim waits 1000ms to determine whether you typed Leader + s or Leader + ss. This was why the display of lsp_symbols felt slow.
I disabled the workspace-level command since I don't use it for now, and it became lightning fast.
By the way, you can check the timeout duration with :set timeoutlen?. Reducing this value would likely have an effect, but using something like Leader + S is probably a better approach.
Conclusion
It works without any issues using the following configuration:
{ "<Leader>s", function() Snacks.picker.lsp_symbols() end, desc = "LSP Symbols" },
{
-- By using S (shift+s), we avoid the Neovim wait time for ambiguity
"<Leader>S",
function() Snacks.picker.lsp_workspace_symbols() end,
desc = "LSP Workspace Symbols",
},
Discussion