mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 15:05:28 +02:00
fix(server): Overall improvements
Signed-off-by: Myzel394 <github.7a2op@simplelogin.co>
This commit is contained in:
parent
7377d952c8
commit
7feb034a84
@ -49,7 +49,7 @@ func checkOption(
|
||||
if option.Separator == nil || option.Separator.Value.Value == "" {
|
||||
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
||||
Range: option.Key.LocationRange.ToLSPRange(),
|
||||
Message: fmt.Sprintf("There should be a separator between an option and its value"),
|
||||
Message: "There should be a separator between an option and its value",
|
||||
Severity: &common.SeverityError,
|
||||
})
|
||||
} else {
|
||||
|
@ -46,7 +46,7 @@ func checkOption(
|
||||
if option.Separator == nil || option.Separator.Value.Value == "" {
|
||||
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
||||
Range: option.Key.LocationRange.ToLSPRange(),
|
||||
Message: fmt.Sprintf("There should be a separator between an option and its value"),
|
||||
Message: "There should be a separator between an option and its value",
|
||||
Severity: &common.SeverityError,
|
||||
})
|
||||
} else {
|
||||
|
@ -94,6 +94,12 @@ func analyzeSymmetricPropertiesSet(
|
||||
}
|
||||
}
|
||||
|
||||
type key int
|
||||
|
||||
const (
|
||||
lineKey key = iota
|
||||
)
|
||||
|
||||
// Strategy
|
||||
// Simply compare the host bits of the IP addresses.
|
||||
// Use a binary tree to store the host bits.
|
||||
@ -117,7 +123,7 @@ func analyzeDuplicateAllowedIPs(
|
||||
}
|
||||
|
||||
if ipContext, _ := ipHostSet.ContainsIP(ipAddress); ipContext != nil {
|
||||
definedLine := (*ipContext).Value("line").(uint32)
|
||||
definedLine := (*ipContext).Value(lineKey).(uint32)
|
||||
|
||||
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
||||
Message: fmt.Sprintf("This IP range is already covered on line %d", definedLine+1),
|
||||
@ -125,7 +131,11 @@ func analyzeDuplicateAllowedIPs(
|
||||
Range: property.ToLSPRange(),
|
||||
})
|
||||
} else {
|
||||
ipContext := context.WithValue(context.Background(), "line", property.Start.Line)
|
||||
ipContext := context.WithValue(
|
||||
context.Background(),
|
||||
lineKey,
|
||||
property.Start.Line,
|
||||
)
|
||||
|
||||
ipHostSet.AddIP(
|
||||
ipAddress,
|
||||
|
@ -144,7 +144,7 @@ func (c *WGConfig) Parse(input string) []common.LSPError {
|
||||
|
||||
indexes := linePattern.FindStringSubmatchIndex(line)
|
||||
|
||||
if indexes == nil || len(indexes) == 0 {
|
||||
if len(indexes) == 0 {
|
||||
// Error
|
||||
errors = append(errors, common.LSPError{
|
||||
Range: common.LocationRange{
|
||||
|
@ -3,14 +3,11 @@ package lsp
|
||||
import (
|
||||
"config-lsp/handlers/wireguard"
|
||||
"config-lsp/handlers/wireguard/handlers"
|
||||
"regexp"
|
||||
|
||||
"github.com/tliron/glsp"
|
||||
protocol "github.com/tliron/glsp/protocol_3_16"
|
||||
)
|
||||
|
||||
var headerPattern = regexp.MustCompile(`^\s*\[(\w+)?]?`)
|
||||
|
||||
func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionParams) (any, error) {
|
||||
d := wireguard.DocumentParserMap[params.TextDocument.URI]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user