mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 15:35:28 +02:00
33 lines
719 B
Go
33 lines
719 B
Go
package wireguard
|
|
|
|
import (
|
|
"github.com/tliron/glsp"
|
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
|
)
|
|
|
|
func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionParams) (any, error) {
|
|
parser := documentParserMap[params.TextDocument.URI]
|
|
|
|
lineNumber := params.Position.Line
|
|
|
|
section := parser.getBelongingSectionByLine(lineNumber)
|
|
lineType := parser.getTypeByLine(lineNumber)
|
|
|
|
switch lineType {
|
|
case LineTypeComment:
|
|
return nil, nil
|
|
case LineTypeHeader:
|
|
return nil, nil
|
|
case LineTypeEmpty:
|
|
if section == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return section.getCompletionsForEmptyLine()
|
|
case LineTypeProperty:
|
|
return nil, nil
|
|
}
|
|
|
|
panic("TextDocumentCompletion: unexpected line type")
|
|
}
|