mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 23:45:27 +02:00
35 lines
708 B
Go
35 lines
708 B
Go
package wireguard
|
|
|
|
import (
|
|
"config-lsp/common"
|
|
"config-lsp/utils"
|
|
|
|
"github.com/tliron/glsp"
|
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
|
)
|
|
|
|
func TextDocumentDidOpen(
|
|
context *glsp.Context,
|
|
params *protocol.DidOpenTextDocumentParams,
|
|
) error {
|
|
common.ClearDiagnostics(context, params.TextDocument.URI)
|
|
|
|
parser := createWireguardParser()
|
|
documentParserMap[params.TextDocument.URI] = &parser
|
|
|
|
errors := parser.parseFromString(params.TextDocument.Text)
|
|
|
|
diagnostics := utils.Map(
|
|
errors,
|
|
func(err common.ParseError) protocol.Diagnostic {
|
|
return err.ToDiagnostic()
|
|
},
|
|
)
|
|
|
|
if len(diagnostics) > 0 {
|
|
common.SendDiagnostics(context, params.TextDocument.URI, diagnostics)
|
|
}
|
|
|
|
return nil
|
|
}
|