mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 23:45:27 +02:00
24 lines
663 B
Go
24 lines
663 B
Go
package lsp
|
|
|
|
import (
|
|
sshdconfig "config-lsp/handlers/sshd_config"
|
|
"config-lsp/handlers/sshd_config/handlers"
|
|
|
|
"github.com/tliron/glsp"
|
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
|
)
|
|
|
|
func TextDocumentDefinition(context *glsp.Context, params *protocol.DefinitionParams) ([]protocol.Location, error) {
|
|
d := sshdconfig.DocumentParserMap[params.TextDocument.URI]
|
|
cursor := params.Position.Character
|
|
line := params.Position.Line
|
|
|
|
if include, found := d.Indexes.Includes[line]; found {
|
|
relativeCursor := cursor - include.Option.LocationRange.Start.Character
|
|
|
|
return handlers.GetIncludeOptionLocation(include, relativeCursor), nil
|
|
}
|
|
|
|
return nil, nil
|
|
}
|