mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 15:05:28 +02:00
feat(ssh_config): Add go to definition support for Tags
This commit is contained in:
parent
eda3a0e771
commit
614463d429
@ -1,10 +1,32 @@
|
||||
package lsp
|
||||
|
||||
import (
|
||||
sshconfig "config-lsp/handlers/ssh_config"
|
||||
"config-lsp/handlers/ssh_config/fields"
|
||||
|
||||
"github.com/tliron/glsp"
|
||||
protocol "github.com/tliron/glsp/protocol_3_16"
|
||||
)
|
||||
|
||||
var tagOption = fields.CreateNormalizedName("Tag")
|
||||
|
||||
func TextDocumentDefinition(context *glsp.Context, params *protocol.DefinitionParams) ([]protocol.Location, error) {
|
||||
line := params.Position.Line
|
||||
|
||||
d := sshconfig.DocumentParserMap[params.TextDocument.URI]
|
||||
|
||||
option, _ := d.Config.FindOption(line)
|
||||
|
||||
if option != nil && option.Key.Key == tagOption && option.OptionValue != nil {
|
||||
if block, found := d.Indexes.Tags[option.OptionValue.Value.Value]; found {
|
||||
return []protocol.Location{
|
||||
{
|
||||
URI: params.TextDocument.URI,
|
||||
Range: block.ToLSPRange(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user