config-lsp/server/handlers/wireguard/lsp/text-document-hover.go
Myzel394 b94d987565
fix(server): Improve wireguard hover lsp
Signed-off-by: Myzel394 <github.7a2op@simplelogin.co>
2025-03-16 00:23:55 +01:00

42 lines
828 B
Go

package lsp
import (
"config-lsp/common"
"config-lsp/handlers/wireguard"
"config-lsp/handlers/wireguard/handlers"
"github.com/tliron/glsp"
protocol "github.com/tliron/glsp/protocol_3_16"
)
func TextDocumentHover(
context *glsp.Context,
params *protocol.HoverParams,
) (*protocol.Hover, error) {
d := wireguard.DocumentParserMap[params.TextDocument.URI]
line := params.Position.Line
section := d.Config.FindSectionByLine(line)
property := d.Config.FindPropertyByLine(line)
index := common.LSPCharacterAsIndexPosition(params.Position.Character)
if property != nil && section != nil {
return handlers.GetPropertyHoverInfo(
d,
*section,
*property,
index,
)
}
if section != nil && section.Start.Line == line {
return handlers.GetSectionHoverInfo(
d,
*section,
)
}
return nil, nil
}