clerk/internal/lsp/config.go (view raw)
| 1 | package lsp |
| 2 | |
| 3 | import ( |
| 4 | "github.com/go-json-experiment/json" |
| 5 | "go.lsp.dev/protocol" |
| 6 | ) |
| 7 | |
| 8 | type Config struct { |
| 9 | SemanticHighlighting bool |
| 10 | |
| 11 | // TODO: Formatter |
| 12 | // TODO: Linter |
| 13 | } |
| 14 | |
| 15 | var DefaultConfig = Config{ |
| 16 | SemanticHighlighting: true, |
| 17 | } |
| 18 | |
| 19 | func (c *Config) merge(v protocol.LSPAny) error { |
| 20 | var patch struct { |
| 21 | SemanticHighlighting *bool `json:"semantic_highlighting,case:ignore"` |
| 22 | } |
| 23 | |
| 24 | if err := json.Unmarshal(v, &patch); err != nil { |
| 25 | return err |
| 26 | } |
| 27 | if patch.SemanticHighlighting != nil { |
| 28 | c.SemanticHighlighting = *patch.SemanticHighlighting |
| 29 | } |
| 30 | return nil |
| 31 | } |
| 32 | |
| 33 | func (s *server) semanticHighlightingEnabled() bool { |
| 34 | s.cfgMu.RLock() |
| 35 | defer s.cfgMu.RUnlock() |
| 36 | return s.config.SemanticHighlighting |
| 37 | } |