Skip to content

Add live as-you-type diagnostics for the cargo backend - #123

Merged
crisidev merged 1 commit into
mainfrom
bigo/live-diagnostics
Apr 27, 2026
Merged

Add live as-you-type diagnostics for the cargo backend#123
crisidev merged 1 commit into
mainfrom
bigo/live-diagnostics

Conversation

@crisidev

Copy link
Copy Markdown
Owner

Forgot to push this yesterday night :)

Opt-in via init_options.cargo.updateOnInsert = true. When enabled, the server hardlinks a shadow copy of the workspace under target/bacon-ls-live/, mirrors dirty buffers from textDocument/didChange into the shadow, and runs cargo there with --remap-path-prefix so diagnostics point at the user's source. Coalesces keystrokes via a configurable debounce (cargo.updateOnInsertDebounceMillis, default 500ms).

The capability has to come through init_options rather than workspace/configuration because the static textDocument/didChange sync mode must be advertised in the initialize response, and clients (Neovim in particular) don't reliably retrofit attached buffers when the server tries to register that capability dynamically post-initialized.

Also redirect the global tracing subscriber set up by test_can_configure_tracing to a tempfile so cargo test no longer clobbers the developer's bacon-ls.log.

Opt-in via `init_options.cargo.updateOnInsert = true`. When enabled, the
server hardlinks a shadow copy of the workspace under
`target/bacon-ls-live/`, mirrors dirty buffers from `textDocument/didChange`
into the shadow, and runs cargo there with `--remap-path-prefix` so
diagnostics point at the user's source. Coalesces keystrokes via a
configurable debounce (`cargo.updateOnInsertDebounceMillis`, default 500ms).

The capability has to come through `init_options` rather than
`workspace/configuration` because the static `textDocument/didChange` sync
mode must be advertised in the initialize response, and clients (Neovim
in particular) don't reliably retrofit attached buffers when the server
tries to register that capability dynamically post-`initialized`.

Also redirect the global tracing subscriber set up by
`test_can_configure_tracing` to a tempfile so `cargo test` no longer
clobbers the developer's `bacon-ls.log`.

Signed-off-by: Matteo Bigoi <bigo@crisidev.org>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.79671% with 113 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.21%. Comparing base (144fe76) to head (aaed552).

Files with missing lines Patch % Lines
src/lib.rs 65.94% 57 Missing and 6 partials ⚠️
src/shadow.rs 88.70% 10 Missing and 18 partials ⚠️
src/lsp.rs 59.25% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   79.03%   79.21%   +0.18%     
==========================================
  Files           5        6       +1     
  Lines        2766     3209     +443     
  Branches     2766     3209     +443     
==========================================
+ Hits         2186     2542     +356     
- Misses        489      554      +65     
- Partials       91      113      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@crisidev
crisidev merged commit 9b604d5 into main Apr 27, 2026
8 of 9 checks passed
@crisidev
crisidev deleted the bigo/live-diagnostics branch April 27, 2026 12:43
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.

2 participants