mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 07:25:27 +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)
|
completions, err := section.getCompletionsForPropertyLine(lineNumber, params.Position.Character)
|
||||||
|
|
||||||
if err != nil {
|
if completions == nil && err != nil {
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
// Ignore
|
// Ignore
|
||||||
case propertyNotFullyTypedError:
|
case propertyNotFullyTypedError:
|
||||||
break
|
return section.getCompletionsForEmptyLine()
|
||||||
default:
|
default:
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,23 @@ func (p wireguardSection) getCompletionsForPropertyLine(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if property.Separator == nil {
|
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
|
var option docvalues.Value
|
||||||
@ -161,7 +177,12 @@ func (p wireguardSection) getCompletionsForPropertyLine(
|
|||||||
|
|
||||||
var validHeaderPattern = regexp.MustCompile(`^\s*\[(?P<header>.+?)\]\s*$`)
|
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)
|
match := validHeaderPattern.FindStringSubmatch(headerLine)
|
||||||
|
|
||||||
var header string
|
var header string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user