z_mirror/luapls

git clone https://git.raiguard.me/z_mirror/luapls

Caleb HeuerGet root files from configuration85d1d1f

main
677 B33 linesraw
1package lsp
2
3import (
4	"encoding/json"
5
6	"github.com/tliron/glsp"
7	protocol "github.com/tliron/glsp/protocol_3_16"
8)
9
10type Config struct {
11	Roots *[]string `json:"roots"`
12}
13
14func (s *Server) didChangeConfiguration(ctx *glsp.Context, params *protocol.DidChangeConfigurationParams) error {
15	return s.updateConfig(params.Settings)
16}
17
18func (s *Server) updateConfig(settings any) error {
19	// Because GLSP gives it to us as `any`, we have to re-marshal it to JSON then unmarshal it again.
20	data, err := json.Marshal(settings)
21	if err != nil {
22		return err
23	}
24
25	var config Config
26	err = json.Unmarshal(data, &config)
27	if err != nil {
28		return err
29	}
30
31	s.config = config
32	return nil
33}