mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
chore: Apply gofmt
This commit is contained in:
parent
403cc9a336
commit
1d55158fc8
@ -14,6 +14,7 @@ type Value interface {
|
|||||||
type EnumValue struct {
|
type EnumValue struct {
|
||||||
Values []string
|
Values []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v EnumValue) getTypeDescription() []string {
|
func (v EnumValue) getTypeDescription() []string {
|
||||||
lines := make([]string, len(v.Values)+1)
|
lines := make([]string, len(v.Values)+1)
|
||||||
lines[0] = "Enum of:"
|
lines[0] = "Enum of:"
|
||||||
@ -26,6 +27,7 @@ func (v EnumValue) getTypeDescription() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PositiveNumberValue struct{}
|
type PositiveNumberValue struct{}
|
||||||
|
|
||||||
func (v PositiveNumberValue) getTypeDescription() []string {
|
func (v PositiveNumberValue) getTypeDescription() []string {
|
||||||
return []string{"Positive number"}
|
return []string{"Positive number"}
|
||||||
}
|
}
|
||||||
@ -35,18 +37,20 @@ type ArrayValue struct {
|
|||||||
Separator string
|
Separator string
|
||||||
AllowDuplicates bool
|
AllowDuplicates bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v ArrayValue) getTypeDescription() []string {
|
func (v ArrayValue) getTypeDescription() []string {
|
||||||
subValue := v.SubValue.(Value)
|
subValue := v.SubValue.(Value)
|
||||||
|
|
||||||
return append(
|
return append(
|
||||||
[]string{"An Array separated by " + v.Separator + " of:"},
|
[]string{"An Array separated by " + v.Separator + " of:"},
|
||||||
subValue.getTypeDescription()...
|
subValue.getTypeDescription()...,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrValue struct {
|
type OrValue struct {
|
||||||
Values []Value
|
Values []Value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v OrValue) getTypeDescription() []string {
|
func (v OrValue) getTypeDescription() []string {
|
||||||
lines := make([]string, 0)
|
lines := make([]string, 0)
|
||||||
|
|
||||||
@ -67,11 +71,12 @@ func (v OrValue) getTypeDescription() []string {
|
|||||||
|
|
||||||
return append(
|
return append(
|
||||||
[]string{"One of:"},
|
[]string{"One of:"},
|
||||||
lines...
|
lines...,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
type StringValue struct{}
|
type StringValue struct{}
|
||||||
|
|
||||||
func (v StringValue) getTypeDescription() []string {
|
func (v StringValue) getTypeDescription() []string {
|
||||||
return []string{"String"}
|
return []string{"String"}
|
||||||
}
|
}
|
||||||
@ -79,6 +84,7 @@ func (v StringValue) getTypeDescription() []string {
|
|||||||
type CustomValue struct {
|
type CustomValue struct {
|
||||||
FetchValue func() Value
|
FetchValue func() Value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v CustomValue) getTypeDescription() []string {
|
func (v CustomValue) getTypeDescription() []string {
|
||||||
return []string{"Custom"}
|
return []string{"Custom"}
|
||||||
}
|
}
|
||||||
@ -91,6 +97,7 @@ type PrefixWithMeaningValue struct {
|
|||||||
Prefixes []Prefix
|
Prefixes []Prefix
|
||||||
SubValue Value
|
SubValue Value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v PrefixWithMeaningValue) getTypeDescription() []string {
|
func (v PrefixWithMeaningValue) getTypeDescription() []string {
|
||||||
subDescription := v.SubValue.getTypeDescription()
|
subDescription := v.SubValue.getTypeDescription()
|
||||||
|
|
||||||
@ -106,7 +113,6 @@ func (v PrefixWithMeaningValue) getTypeDescription() []string {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type Option struct {
|
type Option struct {
|
||||||
Documentation string
|
Documentation string
|
||||||
Value Value
|
Value Value
|
||||||
@ -124,4 +130,3 @@ func GetDocumentation(o *Option) protocol.MarkupContent {
|
|||||||
func NewOption(documentation string, value Value) Option {
|
func NewOption(documentation string, value Value) Option {
|
||||||
return Option{documentation, value}
|
return Option{documentation, value}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ type OptionAlreadyExistsError struct {
|
|||||||
Option string
|
Option string
|
||||||
FoundOnLine uint32
|
FoundOnLine uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e OptionAlreadyExistsError) Error() string {
|
func (e OptionAlreadyExistsError) Error() string {
|
||||||
return fmt.Sprintf("Option %s already exists", e.Option)
|
return fmt.Sprintf("Option %s already exists", e.Option)
|
||||||
}
|
}
|
||||||
@ -18,6 +19,7 @@ func (e OptionAlreadyExistsError) Error() string {
|
|||||||
type OptionUnknownError struct {
|
type OptionUnknownError struct {
|
||||||
Option string
|
Option string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e OptionUnknownError) Error() string {
|
func (e OptionUnknownError) Error() string {
|
||||||
return fmt.Sprintf("Option '%s' does not exist", e.Option)
|
return fmt.Sprintf("Option '%s' does not exist", e.Option)
|
||||||
}
|
}
|
||||||
@ -25,11 +27,13 @@ func (e OptionUnknownError) Error() string {
|
|||||||
type MalformedLineError struct {
|
type MalformedLineError struct {
|
||||||
Line string
|
Line string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e MalformedLineError) Error() string {
|
func (e MalformedLineError) Error() string {
|
||||||
return fmt.Sprintf("Malformed line: %s", e.Line)
|
return fmt.Sprintf("Malformed line: %s", e.Line)
|
||||||
}
|
}
|
||||||
|
|
||||||
type LineNotFoundError struct{}
|
type LineNotFoundError struct{}
|
||||||
|
|
||||||
func (e LineNotFoundError) Error() string {
|
func (e LineNotFoundError) Error() string {
|
||||||
return "Line not found"
|
return "Line not found"
|
||||||
}
|
}
|
||||||
@ -38,7 +42,7 @@ type ValueNotInEnumError struct {
|
|||||||
availableValues []string
|
availableValues []string
|
||||||
providedValue string
|
providedValue string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e ValueNotInEnumError) Error() string {
|
func (e ValueNotInEnumError) Error() string {
|
||||||
return fmt.Sprint("'%s' is not valid. Select one from: %s", e.providedValue, strings.Join(e.availableValues, ","))
|
return fmt.Sprint("'%s' is not valid. Select one from: %s", e.providedValue, strings.Join(e.availableValues, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ func fetchPasswdInfo() ([]passwdInfo, error) {
|
|||||||
return infos, nil
|
return infos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// UserValue returns a Value that fetches user names from /etc/passwd
|
// UserValue returns a Value that fetches user names from /etc/passwd
|
||||||
// if `separatorForMultiple` is not empty, it will return an ArrayValue
|
// if `separatorForMultiple` is not empty, it will return an ArrayValue
|
||||||
func UserValue(separatorForMultiple string) Value {
|
func UserValue(separatorForMultiple string) Value {
|
||||||
@ -80,4 +79,3 @@ func UserValue(separatorForMultiple string) Value {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,4 +144,3 @@ func (p *SimpleConfigParser) FindByLineNumber(lineNumber int) (string, SimpleCon
|
|||||||
|
|
||||||
return "", SimpleConfigLine{Value: "", Position: SimpleConfigPosition{Line: 0}}, LineNotFoundError{}
|
return "", SimpleConfigLine{Value: "", Position: SimpleConfigPosition{Line: 0}}, LineNotFoundError{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,4 +28,3 @@ func Map[T any, O any](values []T, f func(T) O) []O {
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ func SendDiagnosticsFromParserErrors(context *glsp.Context, uri protocol.Documen
|
|||||||
|
|
||||||
for _, parserError := range parserErrors {
|
for _, parserError := range parserErrors {
|
||||||
switch parserError.(type) {
|
switch parserError.(type) {
|
||||||
case common.OptionAlreadyExistsError: {
|
case common.OptionAlreadyExistsError:
|
||||||
|
{
|
||||||
err := parserError.(common.OptionAlreadyExistsError)
|
err := parserError.(common.OptionAlreadyExistsError)
|
||||||
existingOption, _ := Parser.GetOption(err.Option)
|
existingOption, _ := Parser.GetOption(err.Option)
|
||||||
|
|
||||||
@ -53,4 +54,3 @@ func SendDiagnosticsFromParserErrors(context *glsp.Context, uri protocol.Documen
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ See PATTERNS in ssh_config(5) for more information on patterns. This keyword may
|
|||||||
The available authentication methods are: "gssapi-with-mic", "hostbased", "keyboard-interactive", "none" (used for access to password-less accounts when PermitEmptyPasswords is enabled), "password" and "publickey".`,
|
The available authentication methods are: "gssapi-with-mic", "hostbased", "keyboard-interactive", "none" (used for access to password-less accounts when PermitEmptyPasswords is enabled), "password" and "publickey".`,
|
||||||
common.OrValue{
|
common.OrValue{
|
||||||
Values: []common.Value{
|
Values: []common.Value{
|
||||||
common.EnumValue{ Values: []string{"any"}, },
|
common.EnumValue{Values: []string{"any"}},
|
||||||
common.ArrayValue{
|
common.ArrayValue{
|
||||||
AllowDuplicates: true,
|
AllowDuplicates: true,
|
||||||
SubValue: common.EnumValue{
|
SubValue: common.EnumValue{
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
func createOpenSSHConfigParser() common.SimpleConfigParser {
|
func createOpenSSHConfigParser() common.SimpleConfigParser {
|
||||||
pattern, err := regexp.Compile(`^(?:#|\s*$)`)
|
pattern, err := regexp.Compile(`^(?:#|\s*$)`)
|
||||||
|
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,4 +23,3 @@ func createOpenSSHConfigParser() common.SimpleConfigParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var Parser = createOpenSSHConfigParser()
|
var Parser = createOpenSSHConfigParser()
|
||||||
|
|
||||||
|
@ -100,4 +100,3 @@ func getOptionCompletions(optionName string) []protocol.CompletionItem {
|
|||||||
|
|
||||||
return completions
|
return completions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,5 @@ func TextDocumentDidChange(context *glsp.Context, params *protocol.DidChangeText
|
|||||||
ClearDiagnostics(context, params.TextDocument.URI)
|
ClearDiagnostics(context, params.TextDocument.URI)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,3 @@ func TextDocumentDidOpen(context *glsp.Context, params *protocol.DidOpenTextDocu
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user