Skip to content

Add support for range diagnostics under cursor #1586

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

satorunooshie
Copy link
Contributor

Added support for range-based diagnostics, aligning with the Language Server Protocol (LSP) Specification.
Previously, diagnostics were matched only to specific start positions, limiting usability for multi-line or range diagnostics.
This update ensures vim-lsp provides functionality consistent with VSCode, which already supports range-based diagnostics.

The highlighted codes represents the area where textDocument/codeAction can be triggered.
Below is the corresponding diff for the changes.

Before

before

After

after

VSCode behavior

vscode

@satorunooshie
Copy link
Contributor Author

@prabirshrestha Merry Christmas! 🎄
Just wanted to kindly ping. Let me know if there’s anything I can adjust or clarify.

Thanks, and hope you’re having a great holiday season!

@prabirshrestha
Copy link
Owner

@satorunooshie can you provide the steps to use. i don't see much difference.

@satorunooshie
Copy link
Contributor Author

@prabirshrestha Thanks for responding and I'm sorry I'm late.

package main

import "fmt"

func documentDiagnostics() {
	msg := "msg"
	fmt.Printf(msg +
		msg +
		msg,
	)
}

When using a Go language server (e.g., gopls), you might see a warning like:

non-constant format string in call to fmt.Printf

involving lines 7–9. This PR enables vim-lsp to highlight the exact range rather than just the line 7.

Why does this matter?

  • Accurate Highlighting: Multi-line warnings/errors get highlighted precisely.

  • Better Quickfix & Code Actions: When the diagnostics cover the correct range, automated fixes (e.g., Quickfix or code actions) apply cleanly.

  • Consistent with VSCode/LSP spec: This matches the standard Language Server Protocol behavior, which supports start/end positions for diagnostics.

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