mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package openssh
|
|
|
|
import (
|
|
"config-lsp/common"
|
|
|
|
"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()
|
|
diagnostics := make([]protocol.Diagnostic, 0)
|
|
|
|
diagnostics = append(
|
|
diagnostics,
|
|
common.Map(
|
|
Parser.ParseFromFile(content),
|
|
func (err common.OptionError) protocol.Diagnostic {
|
|
return err.GetPublishDiagnosticsParams()
|
|
},
|
|
)...,
|
|
)
|
|
|
|
diagnostics = append(
|
|
diagnostics,
|
|
common.Map(
|
|
common.AnalyzeValues(Parser, Options),
|
|
func (err common.ValueError) protocol.Diagnostic {
|
|
return err.GetPublishDiagnosticsParams()
|
|
},
|
|
)...,
|
|
)
|
|
|
|
if len(diagnostics) > 0 {
|
|
common.SendDiagnostics(context, params.TextDocument.URI, diagnostics)
|
|
} else {
|
|
common.ClearDiagnostics(context, params.TextDocument.URI)
|
|
}
|
|
|
|
return nil
|
|
}
|