config-lsp/handlers/openssh/text-document-did-change.go
2024-07-28 18:05:24 +02:00

23 lines
575 B
Go

package handlers
import (
"github.com/tliron/glsp"
protocol "github.com/tliron/glsp/protocol_3_16"
)
// Todo: Implement incremental parsing
func TextDocumentDidChange(context *glsp.Context, params *protocol.DidChangeTextDocumentParams) error {
content := params.ContentChanges[0].(protocol.TextDocumentContentChangeEventWhole).Text
Parser.Clear()
errors := Parser.ParseFromFile(content)
if len(errors) > 0 {
SendDiagnosticsFromParserErrors(context, params.TextDocument.URI, errors)
} else {
ClearDiagnostics(context, params.TextDocument.URI)
}
return nil
}