-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.go
More file actions
64 lines (54 loc) · 1.53 KB
/
Copy pathsettings.go
File metadata and controls
64 lines (54 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"sync"
protocol "github.com/tliron/glsp/protocol_3_16"
)
// Settings holds user-configurable options for the language server
type Settings struct {
// DiagnosticSeverity controls the severity level for detected secrets
// Valid values: "error", "warning", "information", "hint"
// Default: "warning"
DiagnosticSeverity string `json:"diagnosticSeverity"`
}
// DefaultSettings returns the default configuration
func DefaultSettings() *Settings {
return &Settings{
DiagnosticSeverity: "warning",
}
}
// Global settings instance
var (
settingsMu sync.RWMutex
serverSettings = DefaultSettings()
)
// GetDiagnosticSeverity returns the LSP severity based on settings
func GetDiagnosticSeverity() protocol.DiagnosticSeverity {
settingsMu.RLock()
severity := serverSettings.DiagnosticSeverity
settingsMu.RUnlock()
switch severity {
case "error":
return protocol.DiagnosticSeverityError
case "warning":
return protocol.DiagnosticSeverityWarning
case "information":
return protocol.DiagnosticSeverityInformation
case "hint":
return protocol.DiagnosticSeverityHint
default:
return protocol.DiagnosticSeverityWarning
}
}
// UpdateSettings updates server settings from client configuration
func UpdateSettings(config map[string]interface{}) {
if config == nil {
return
}
settingsMu.Lock()
defer settingsMu.Unlock()
if gitleaks, ok := config["gitleaks"].(map[string]interface{}); ok {
if severity, ok := gitleaks["diagnosticSeverity"].(string); ok {
serverSettings.DiagnosticSeverity = severity
}
}
}