mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
feat(handlers): Working on the WIP
This commit is contained in:
parent
4aa54ffcc1
commit
54c4f516fe
@ -246,15 +246,15 @@ var DefaultMountOptionsField = createMountOptionField([]docvalues.EnumString{},
|
|||||||
|
|
||||||
var MountOptionsMapField = map[string]docvalues.Value{
|
var MountOptionsMapField = map[string]docvalues.Value{
|
||||||
"adfs": createMountOptionField(
|
"adfs": createMountOptionField(
|
||||||
[]docvalues.EnumString{},
|
commondocumentation.AdfsDocumentationEnums,
|
||||||
commondocumentation.AdfsDocumentationAssignable,
|
commondocumentation.AdfsDocumentationAssignable,
|
||||||
),
|
),
|
||||||
"affs": createMountOptionField(
|
"affs": createMountOptionField(
|
||||||
[]docvalues.EnumString{},
|
commondocumentation.AffsDocumentationEnums,
|
||||||
commondocumentation.AffsDocumentationAssignable,
|
commondocumentation.AffsDocumentationAssignable,
|
||||||
),
|
),
|
||||||
"debugfs": createMountOptionField(
|
"debugfs": createMountOptionField(
|
||||||
[]docvalues.EnumString{},
|
commondocumentation.DebugfsDocumentationEnums,
|
||||||
commondocumentation.DebugfsDocumentationAssignable,
|
commondocumentation.DebugfsDocumentationAssignable,
|
||||||
),
|
),
|
||||||
"ext2": createMountOptionField(
|
"ext2": createMountOptionField(
|
||||||
|
@ -1,108 +1,20 @@
|
|||||||
package fstabdocumentation
|
package fstabdocumentation
|
||||||
|
|
||||||
import docvalues "config-lsp/doc-values"
|
import (
|
||||||
|
docvalues "config-lsp/doc-values"
|
||||||
|
"config-lsp/utils"
|
||||||
|
)
|
||||||
|
|
||||||
var FileSystemTypeField = docvalues.ArrayValue{
|
var FileSystemTypeField = docvalues.ArrayValue{
|
||||||
Separator: ",",
|
Separator: ",",
|
||||||
DuplicatesExtractor: &docvalues.SimpleDuplicatesExtractor,
|
DuplicatesExtractor: &docvalues.SimpleDuplicatesExtractor,
|
||||||
SubValue: docvalues.EnumValue{
|
SubValue: docvalues.EnumValue{
|
||||||
EnforceValues: false,
|
EnforceValues: false,
|
||||||
Values: []docvalues.EnumString{
|
Values: utils.Map(
|
||||||
{
|
utils.KeysOfMap(MountOptionsMapField),
|
||||||
InsertText: "none",
|
func(key string) docvalues.EnumString {
|
||||||
DescriptionText: "none",
|
return docvalues.CreateEnumString(key)
|
||||||
Documentation: "An entry _none_ is useful for bind or move mounts.",
|
|
||||||
},
|
},
|
||||||
{
|
),
|
||||||
InsertText: "swap",
|
|
||||||
DescriptionText: "swap",
|
|
||||||
Documentation: "An entry _swap_ denotes a file or partition to be used for swapping, cf. swapon(8)",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "ext2",
|
|
||||||
DescriptionText: "ext2",
|
|
||||||
Documentation: "Mount as ext2 filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "ext3",
|
|
||||||
DescriptionText: "ext3",
|
|
||||||
Documentation: "Mount as ext2 filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "ext4",
|
|
||||||
DescriptionText: "ext4",
|
|
||||||
Documentation: "Mount as ext4 filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "xfs",
|
|
||||||
DescriptionText: "xfs",
|
|
||||||
Documentation: "Mount as xfs filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "btrfs",
|
|
||||||
DescriptionText: "btrfs",
|
|
||||||
Documentation: "Mount as btrfs filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "f2fs",
|
|
||||||
DescriptionText: "f2fs",
|
|
||||||
Documentation: "Mount as f2fs filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "vfat",
|
|
||||||
DescriptionText: "vfat",
|
|
||||||
Documentation: "Mount as vfat filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "ntfs",
|
|
||||||
DescriptionText: "ntfs",
|
|
||||||
Documentation: "Mount as ntfs filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "hfsplus",
|
|
||||||
DescriptionText: "hfsplus",
|
|
||||||
Documentation: "Mount as hfsplus filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "tmpfs",
|
|
||||||
DescriptionText: "tmpfs",
|
|
||||||
Documentation: "Mount as tmpfs filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "sysfs",
|
|
||||||
DescriptionText: "sysfs",
|
|
||||||
Documentation: "Mount as sysfs filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "proc",
|
|
||||||
DescriptionText: "proc",
|
|
||||||
Documentation: "Mount as proc filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "iso9660",
|
|
||||||
DescriptionText: "iso9660",
|
|
||||||
Documentation: "Mount as iso9660 filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "udf",
|
|
||||||
DescriptionText: "udf",
|
|
||||||
Documentation: "Mount as udf filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "squashfs",
|
|
||||||
DescriptionText: "squashfs",
|
|
||||||
Documentation: "Mount as squashfs filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "nfs",
|
|
||||||
DescriptionText: "nfs",
|
|
||||||
Documentation: "Mount as nfs filesystem",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
InsertText: "cifs",
|
|
||||||
DescriptionText: "cifs",
|
|
||||||
Documentation: "Mount as cifs filesystem",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package fstab
|
|||||||
import (
|
import (
|
||||||
docvalues "config-lsp/doc-values"
|
docvalues "config-lsp/doc-values"
|
||||||
fstabdocumentation "config-lsp/handlers/fstab/documentation"
|
fstabdocumentation "config-lsp/handlers/fstab/documentation"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/tliron/glsp"
|
"github.com/tliron/glsp"
|
||||||
protocol "github.com/tliron/glsp/protocol_3_16"
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
||||||
@ -25,8 +24,6 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
|
|||||||
cursor := params.Position.Character
|
cursor := params.Position.Character
|
||||||
targetField := entry.GetFieldAtPosition(cursor - 1)
|
targetField := entry.GetFieldAtPosition(cursor - 1)
|
||||||
|
|
||||||
println("cursor at", cursor, "target field", targetField)
|
|
||||||
|
|
||||||
switch targetField {
|
switch targetField {
|
||||||
case FstabFieldSpec:
|
case FstabFieldSpec:
|
||||||
value, cursor := GetFieldSafely(entry.Fields.Spec, cursor)
|
value, cursor := GetFieldSafely(entry.Fields.Spec, cursor)
|
||||||
@ -43,9 +40,7 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
|
|||||||
cursor,
|
cursor,
|
||||||
), nil
|
), nil
|
||||||
case FstabFieldFileSystemType:
|
case FstabFieldFileSystemType:
|
||||||
println(fmt.Sprintf("file system type: %s", entry.Fields.FilesystemType))
|
|
||||||
value, cursor := GetFieldSafely(entry.Fields.FilesystemType, cursor)
|
value, cursor := GetFieldSafely(entry.Fields.FilesystemType, cursor)
|
||||||
println("CURSOR", cursor)
|
|
||||||
|
|
||||||
return fstabdocumentation.FileSystemTypeField.FetchCompletions(
|
return fstabdocumentation.FileSystemTypeField.FetchCompletions(
|
||||||
value,
|
value,
|
||||||
@ -64,10 +59,12 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
|
|||||||
|
|
||||||
value, cursor := GetFieldSafely(entry.Fields.Options, cursor)
|
value, cursor := GetFieldSafely(entry.Fields.Options, cursor)
|
||||||
|
|
||||||
return optionsField.FetchCompletions(
|
completions := optionsField.FetchCompletions(
|
||||||
value,
|
value,
|
||||||
cursor,
|
cursor,
|
||||||
), nil
|
)
|
||||||
|
|
||||||
|
return completions, nil
|
||||||
case FstabFieldFreq:
|
case FstabFieldFreq:
|
||||||
value, cursor := GetFieldSafely(entry.Fields.Freq, cursor)
|
value, cursor := GetFieldSafely(entry.Fields.Freq, cursor)
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ import (
|
|||||||
func TextDocumentDidOpen(context *glsp.Context, params *protocol.DidOpenTextDocumentParams) error {
|
func TextDocumentDidOpen(context *glsp.Context, params *protocol.DidOpenTextDocumentParams) error {
|
||||||
readBytes, err := os.ReadFile(params.TextDocument.URI[len("file://"):])
|
readBytes, err := os.ReadFile(params.TextDocument.URI[len("file://"):])
|
||||||
|
|
||||||
println("opened i la language eta", params.TextDocument.LanguageID)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user