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 {
|
||||
Values []string
|
||||
}
|
||||
|
||||
func (v EnumValue) getTypeDescription() []string {
|
||||
lines := make([]string, len(v.Values)+1)
|
||||
lines[0] = "Enum of:"
|
||||
@ -26,6 +27,7 @@ func (v EnumValue) getTypeDescription() []string {
|
||||
}
|
||||
|
||||
type PositiveNumberValue struct{}
|
||||
|
||||
func (v PositiveNumberValue) getTypeDescription() []string {
|
||||
return []string{"Positive number"}
|
||||
}
|
||||
@ -35,18 +37,20 @@ type ArrayValue struct {
|
||||
Separator string
|
||||
AllowDuplicates bool
|
||||
}
|
||||
|
||||
func (v ArrayValue) getTypeDescription() []string {
|
||||
subValue := v.SubValue.(Value)
|
||||
|
||||
return append(
|
||||
[]string{"An Array separated by " + v.Separator + " of:"},
|
||||
subValue.getTypeDescription()...
|
||||
subValue.getTypeDescription()...,
|
||||
)
|
||||
}
|
||||
|
||||
type OrValue struct {
|
||||
Values []Value
|
||||
}
|
||||
|
||||
func (v OrValue) getTypeDescription() []string {
|
||||
lines := make([]string, 0)
|
||||
|
||||
@ -67,11 +71,12 @@ func (v OrValue) getTypeDescription() []string {
|
||||
|
||||
return append(
|
||||
[]string{"One of:"},
|
||||
lines...
|
||||
lines...,
|
||||
)
|
||||
}
|
||||
|
||||
type StringValue struct{}
|
||||
|
||||
func (v StringValue) getTypeDescription() []string {
|
||||
return []string{"String"}
|
||||
}
|
||||
@ -79,6 +84,7 @@ func (v StringValue) getTypeDescription() []string {
|
||||
type CustomValue struct {
|
||||
FetchValue func() Value
|
||||
}
|
||||
|
||||
func (v CustomValue) getTypeDescription() []string {
|
||||
return []string{"Custom"}
|
||||
}
|
||||
@ -91,6 +97,7 @@ type PrefixWithMeaningValue struct {
|
||||
Prefixes []Prefix
|
||||
SubValue Value
|
||||
}
|
||||
|
||||
func (v PrefixWithMeaningValue) getTypeDescription() []string {
|
||||
subDescription := v.SubValue.getTypeDescription()
|
||||
|
||||
@ -106,7 +113,6 @@ func (v PrefixWithMeaningValue) getTypeDescription() []string {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
type Option struct {
|
||||
Documentation string
|
||||
Value Value
|
||||
@ -124,4 +130,3 @@ func GetDocumentation(o *Option) protocol.MarkupContent {
|
||||
func NewOption(documentation string, value Value) Option {
|
||||
return Option{documentation, value}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ type OptionAlreadyExistsError struct {
|
||||
Option string
|
||||
FoundOnLine uint32
|
||||
}
|
||||
|
||||
func (e OptionAlreadyExistsError) Error() string {
|
||||
return fmt.Sprintf("Option %s already exists", e.Option)
|
||||
}
|
||||
@ -18,6 +19,7 @@ func (e OptionAlreadyExistsError) Error() string {
|
||||
type OptionUnknownError struct {
|
||||
Option string
|
||||
}
|
||||
|
||||
func (e OptionUnknownError) Error() string {
|
||||
return fmt.Sprintf("Option '%s' does not exist", e.Option)
|
||||
}
|
||||
@ -25,11 +27,13 @@ func (e OptionUnknownError) Error() string {
|
||||
type MalformedLineError struct {
|
||||
Line string
|
||||
}
|
||||
|
||||
func (e MalformedLineError) Error() string {
|
||||
return fmt.Sprintf("Malformed line: %s", e.Line)
|
||||
}
|
||||
|
||||
type LineNotFoundError struct{}
|
||||
|
||||
func (e LineNotFoundError) Error() string {
|
||||
return "Line not found"
|
||||
}
|
||||
@ -38,7 +42,7 @@ type ValueNotInEnumError struct {
|
||||
availableValues []string
|
||||
providedValue string
|
||||
}
|
||||
|
||||
func (e ValueNotInEnumError) Error() string {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
// UserValue returns a Value that fetches user names from /etc/passwd
|
||||
// if `separatorForMultiple` is not empty, it will return an ArrayValue
|
||||
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{}
|
||||
}
|
||||
|
||||
|
@ -28,4 +28,3 @@ func Map[T any, O any](values []T, f func(T) O) []O {
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,8 @@ func SendDiagnosticsFromParserErrors(context *glsp.Context, uri protocol.Documen
|
||||
|
||||
for _, parserError := range parserErrors {
|
||||
switch parserError.(type) {
|
||||
case common.OptionAlreadyExistsError: {
|
||||
case common.OptionAlreadyExistsError:
|
||||
{
|
||||
err := parserError.(common.OptionAlreadyExistsError)
|
||||
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".`,
|
||||
common.OrValue{
|
||||
Values: []common.Value{
|
||||
common.EnumValue{ Values: []string{"any"}, },
|
||||
common.EnumValue{Values: []string{"any"}},
|
||||
common.ArrayValue{
|
||||
AllowDuplicates: true,
|
||||
SubValue: common.EnumValue{
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
func createOpenSSHConfigParser() common.SimpleConfigParser {
|
||||
pattern, err := regexp.Compile(`^(?:#|\s*$)`)
|
||||
|
||||
if (err != nil) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -23,4 +23,3 @@ func createOpenSSHConfigParser() common.SimpleConfigParser {
|
||||
}
|
||||
|
||||
var Parser = createOpenSSHConfigParser()
|
||||
|
||||
|
@ -100,4 +100,3 @@ func getOptionCompletions(optionName string) []protocol.CompletionItem {
|
||||
|
||||
return completions
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,5 @@ func TextDocumentDidChange(context *glsp.Context, params *protocol.DidChangeText
|
||||
ClearDiagnostics(context, params.TextDocument.URI)
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -22,5 +22,3 @@ func TextDocumentDidOpen(context *glsp.Context, params *protocol.DidOpenTextDocu
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user