all repos

clerk @ 64f0a9d

missing tooling for ledger/hledger

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

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
lsp: add config, 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) {
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
26
	}
27
	if patch.SemanticHighlighting != nil {
28
		c.SemanticHighlighting = *patch.SemanticHighlighting
29
	}
30
}
31
32
func (s *server) semanticHighlightingEnabled() bool {
33
	s.cfgMu.RLock()
34
	defer s.cfgMu.RUnlock()
35
	return s.config.SemanticHighlighting
36
}