mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
38 lines
776 B
Go
38 lines
776 B
Go
package shared
|
|
|
|
import (
|
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
|
)
|
|
|
|
var Handler RootHandler
|
|
|
|
var OpenedFiles = make(map[protocol.DocumentUri]struct{})
|
|
|
|
type RootHandler struct {
|
|
languageMap map[protocol.DocumentUri]SupportedLanguage
|
|
}
|
|
|
|
func NewRootHandler() RootHandler {
|
|
return RootHandler{
|
|
languageMap: make(map[protocol.DocumentUri]SupportedLanguage),
|
|
}
|
|
}
|
|
|
|
func (h *RootHandler) AddDocument(uri protocol.DocumentUri, language SupportedLanguage) {
|
|
h.languageMap[uri] = language
|
|
}
|
|
|
|
func (h *RootHandler) GetLanguageForDocument(uri protocol.DocumentUri) *SupportedLanguage {
|
|
language, found := h.languageMap[uri]
|
|
|
|
if !found {
|
|
return nil
|
|
}
|
|
|
|
return &language
|
|
}
|
|
|
|
func (h *RootHandler) RemoveDocument(uri protocol.DocumentUri) {
|
|
delete(h.languageMap, uri)
|
|
}
|