mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 15:05:28 +02:00
feat(server): Improve completions for fsck
This commit is contained in:
parent
387c2f2b61
commit
66f8b36e74
@ -3,6 +3,7 @@ package analyzer
|
||||
import (
|
||||
"config-lsp/common"
|
||||
"config-lsp/handlers/fstab/ast"
|
||||
"config-lsp/handlers/fstab/fields"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@ -20,7 +21,7 @@ func analyzeFSCKField(ctx *analyzerContext) {
|
||||
if entry.Fields != nil && entry.Fields.Fsck != nil && entry.Fields.Fsck.Value.Value == "1" {
|
||||
fileSystem := strings.ToLower(entry.Fields.FilesystemType.Value.Value)
|
||||
|
||||
if fileSystem == "btrfs" || fileSystem == "xfs" {
|
||||
if _, found := fields.FsckOneDisabledFilesystems[fileSystem]; found {
|
||||
// From https://wiki.archlinux.org/title/Fstab
|
||||
|
||||
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
||||
|
@ -19,3 +19,22 @@ var FsckField = docvalues.EnumValue{
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
var FsckFieldWhenDisabledFilesystems = docvalues.EnumValue{
|
||||
EnforceValues: false,
|
||||
Values: []docvalues.EnumString{
|
||||
docvalues.CreateEnumStringWithDoc(
|
||||
"0",
|
||||
"Defaults to zero (don’t check the filesystem) if not present.",
|
||||
),
|
||||
docvalues.CreateEnumStringWithDoc(
|
||||
"2",
|
||||
"Other filesystems [than the root filesystem] should have a fs_passno of 2.",
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
var FsckOneDisabledFilesystems = map[string]struct{}{
|
||||
"btrfs": {},
|
||||
"xfs": {},
|
||||
}
|
||||
|
@ -4,7 +4,9 @@ import (
|
||||
"config-lsp/common"
|
||||
"config-lsp/handlers/fstab/ast"
|
||||
"config-lsp/handlers/fstab/fields"
|
||||
"config-lsp/utils"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/tliron/glsp/protocol_3_16"
|
||||
)
|
||||
@ -87,10 +89,18 @@ func GetCompletion(
|
||||
case ast.FstabFieldFsck:
|
||||
value, cursor := getFieldSafely(entry.Fields.Fsck, cursor)
|
||||
|
||||
return fields.FsckField.DeprecatedFetchCompletions(
|
||||
value,
|
||||
cursor,
|
||||
), nil
|
||||
if entry.Fields.FilesystemType != nil &&
|
||||
utils.KeyExists(fields.FsckOneDisabledFilesystems, strings.ToLower(entry.Fields.FilesystemType.Value.Value)) {
|
||||
return fields.FsckFieldWhenDisabledFilesystems.DeprecatedFetchCompletions(
|
||||
value,
|
||||
cursor,
|
||||
), nil
|
||||
} else {
|
||||
return fields.FsckField.DeprecatedFetchCompletions(
|
||||
value,
|
||||
cursor,
|
||||
), nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user