Skip to content

fix(#2954): more efficient LSP updates, increase diagnostics.debounce_delay from 50ms to 500ms #3007

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

Merged
merged 3 commits into from
Nov 21, 2024

Conversation

alex-courtis
Copy link
Member

@alex-courtis alex-courtis commented Nov 18, 2024

fixes #2954

@des-b I'd be most grateful for your review and thoughts.

This changes the approach to LSP:

  • examine the DiagnosticChanged data on the event (sync) thread
  • NODE_SEVERITIES and NODE_SEVERITIES_VERSION only updated on delta
  • on delta a redraw is scheduled

The debounce delay was increased as there are a lot of events as the user types.

It's not clear whether a full redraw R is needed; it could clear NODE_SEVERITIES and rebuild it. YAGNI?

@@ -135,35 +108,77 @@ local function from_cache(node)
for bufname, severity in pairs(NODE_SEVERITIES) do
local node_contains_buf = vim.startswith(bufname, nodepath .. "/")
if node_contains_buf then
if severity == M.severity.max then
if not max_severity or severity < max_severity then
Copy link
Member Author

Choose a reason for hiding this comment

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

This became a warning hence it was simplified.

@@ -17,7 +17,7 @@ local COC_SEVERITY_LEVELS = {
}

---Absolute Node path to LSP severity level
---@alias NodeSeverities table<string, lsp.DiagnosticSeverity>
---@alias NodeSeverities table<string, vim.diagnostic.Severity>
Copy link
Member Author

Choose a reason for hiding this comment

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

lsp.DiagnosticSeverity and vim.diagnostic.Severity are effectively the same. It's not clear which is preferred, so I went with the one from vim.Diagnostic

@alex-courtis alex-courtis merged commit 1f3ffd6 into master Nov 21, 2024
5 checks passed
@alex-courtis alex-courtis deleted the 2954-remove-unnecessary-lsp-updates branch November 21, 2024 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LSP diagnostics inside nvim-tree may flicker
1 participant