mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
fix(wireguard): Improvements
This commit is contained in:
parent
0d2c986ddd
commit
431d63d440
@ -31,11 +31,11 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
|
||||
|
||||
completions, err := section.getCompletionsForPropertyLine(lineNumber, params.Position.Character)
|
||||
|
||||
if err != nil {
|
||||
if completions == nil && err != nil {
|
||||
switch err.(type) {
|
||||
// Ignore
|
||||
case propertyNotFullyTypedError:
|
||||
break
|
||||
return section.getCompletionsForEmptyLine()
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
|
@ -132,7 +132,23 @@ func (p wireguardSection) getCompletionsForPropertyLine(
|
||||
}
|
||||
|
||||
if property.Separator == nil {
|
||||
return getSeparatorCompletion(*property, character)
|
||||
if p.Name != nil {
|
||||
switch *p.Name {
|
||||
case "Interface":
|
||||
if _, found := interfaceOptions[property.Key.Name]; found {
|
||||
return getSeparatorCompletion(*property, character)
|
||||
}
|
||||
case "Peer":
|
||||
if _, found := peerOptions[property.Key.Name]; found {
|
||||
return getSeparatorCompletion(*property, character)
|
||||
}
|
||||
}
|
||||
|
||||
// Get empty line completions
|
||||
return nil, propertyNotFullyTypedError{}
|
||||
}
|
||||
|
||||
return nil, propertyNotFoundError{}
|
||||
}
|
||||
|
||||
var option docvalues.Value
|
||||
@ -161,7 +177,12 @@ func (p wireguardSection) getCompletionsForPropertyLine(
|
||||
|
||||
var validHeaderPattern = regexp.MustCompile(`^\s*\[(?P<header>.+?)\]\s*$`)
|
||||
|
||||
func createWireguardSection(startLine uint32, endLine uint32, headerLine string, props wireguardProperties) wireguardSection {
|
||||
func createWireguardSection(
|
||||
startLine uint32,
|
||||
endLine uint32,
|
||||
headerLine string,
|
||||
props wireguardProperties,
|
||||
) wireguardSection {
|
||||
match := validHeaderPattern.FindStringSubmatch(headerLine)
|
||||
|
||||
var header string
|
||||
|
Loading…
x
Reference in New Issue
Block a user