swiftlang / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages
Apache License 2.0
3.34k stars 280 forks source link

Slow diagnostics in Neovim after updating to 6.0 #1753

Closed jayadamsmorgan closed 1 month ago

jayadamsmorgan commented 1 month ago

Swift version

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)

Platform

macOS 15.0.1

Editor

Neovim (lspconfig)

Description

Experiencing much longer delay in diagnostics since upgrading to 6.0 toolchain from 5.10, diagnostics take about 3-4 seconds just to show up, completions are completely fine though and work fast enough.

Steps to Reproduce

  1. swift package init
  2. swift build
  3. Open project in Neovim

Logging

sourcekit-lsp-diagnose-2024-10-11T10-58-58-04-00.zip

diocletiann commented 1 month ago

I have the same issue.

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx14.0

NVIM v0.11.0-dev-965+gfb74fd295
Build type: Release
LuaJIT 2.1.1727870382
ahoppen commented 1 month ago

SourceKit-LSP has a debounce duration of 2s by default between edits and sending diagnostics from the to the editor. You can customize this debounce by setting ` in your Configuration File. Adjusting that value should fix the issue. Let me know if it doesn’t.

And thanks for your feedback, I’m reducing the debounce duration to 1s in the next version of SourceKit-LSP here: https://github.com/swiftlang/sourcekit-lsp/pull/1755

ahoppen commented 1 month ago

Synced to Apple’s issue tracker as rdar://137886466

diocletiann commented 1 month ago

SourceKit-LSP has a debounce duration of 2s by default between edits and sending diagnostics from the to the editor. You can customize this debounce by setting ` in your Configuration File. Adjusting that value should fix the issue. Let me know if it doesn’t.

And thanks for your feedback, I’m reducing the debounce duration to 1s in the next version of SourceKit-LSP here: #1755

Thanks for the update. Is this correct in .sourcekit-lsp/config.json?

{
  "backgroundIndexing": true,
  "swiftPublishDiagnosticsDebounce": 1
}

I also noticed the diag instant in Sublime Text but delayed in Neovim, does the Sublime plugin alter this setting?

ahoppen commented 1 month ago

That config file looks good to me.

I suppose that Sublime Text uses the pull-based textDocument/diagnostic request, so it can decide when to show diagnostics (presumably also debounced to some degree, but I don’t know how much).

You neovim uses the older push-based textDocument/publishDiagnostics notification, where SourceKit-LSP controls the debounce duration using swiftPublishDiagnosticsDebounce.

jayadamsmorgan commented 1 month ago

Thanks for your response! Setting this property in the config fixed the issue, however documentation is a bit off exactly on this property so I created a PR #1756 to fix it.

So the correct config for @diocletiann would be:

{
  "backgroundIndexing": true,
  "swiftPublishDiagnosticsDebounceDuration": 1
}

Thanks again, keep up the great work!