all repos

clerk @ 1f6bd77466d05af3033931d98b68dc9c430fa662

missing tooling for ledger/hledger

clerk/internal/lsp/config.go (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
lsp: move code around, 2 months ago
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
}