From 54c4f516fe1c9b3aa43ff9e11eebed71c159089d Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Wed, 7 Aug 2024 22:35:30 +0200 Subject: [PATCH] feat(handlers): Working on the WIP --- .../documentation-mountoptions.go | 6 +- .../fstab/documentation/documentation-type.go | 106 ++---------------- handlers/fstab/text-document-completion.go | 11 +- handlers/openssh/text-document-did-open.go | 2 - 4 files changed, 16 insertions(+), 109 deletions(-) diff --git a/handlers/fstab/documentation/documentation-mountoptions.go b/handlers/fstab/documentation/documentation-mountoptions.go index 40d0a6e..cc17c9d 100644 --- a/handlers/fstab/documentation/documentation-mountoptions.go +++ b/handlers/fstab/documentation/documentation-mountoptions.go @@ -246,15 +246,15 @@ var DefaultMountOptionsField = createMountOptionField([]docvalues.EnumString{}, var MountOptionsMapField = map[string]docvalues.Value{ "adfs": createMountOptionField( - []docvalues.EnumString{}, + commondocumentation.AdfsDocumentationEnums, commondocumentation.AdfsDocumentationAssignable, ), "affs": createMountOptionField( - []docvalues.EnumString{}, + commondocumentation.AffsDocumentationEnums, commondocumentation.AffsDocumentationAssignable, ), "debugfs": createMountOptionField( - []docvalues.EnumString{}, + commondocumentation.DebugfsDocumentationEnums, commondocumentation.DebugfsDocumentationAssignable, ), "ext2": createMountOptionField( diff --git a/handlers/fstab/documentation/documentation-type.go b/handlers/fstab/documentation/documentation-type.go index c159b62..8a6f8f8 100644 --- a/handlers/fstab/documentation/documentation-type.go +++ b/handlers/fstab/documentation/documentation-type.go @@ -1,108 +1,20 @@ package fstabdocumentation -import docvalues "config-lsp/doc-values" +import ( + docvalues "config-lsp/doc-values" + "config-lsp/utils" +) var FileSystemTypeField = docvalues.ArrayValue{ Separator: ",", DuplicatesExtractor: &docvalues.SimpleDuplicatesExtractor, SubValue: docvalues.EnumValue{ EnforceValues: false, - Values: []docvalues.EnumString{ - { - InsertText: "none", - DescriptionText: "none", - Documentation: "An entry _none_ is useful for bind or move mounts.", + Values: utils.Map( + utils.KeysOfMap(MountOptionsMapField), + func(key string) docvalues.EnumString { + return docvalues.CreateEnumString(key) }, - { - 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", - }, - }, + ), }, } diff --git a/handlers/fstab/text-document-completion.go b/handlers/fstab/text-document-completion.go index ff800cf..0378f68 100644 --- a/handlers/fstab/text-document-completion.go +++ b/handlers/fstab/text-document-completion.go @@ -3,7 +3,6 @@ package fstab import ( docvalues "config-lsp/doc-values" fstabdocumentation "config-lsp/handlers/fstab/documentation" - "fmt" "github.com/tliron/glsp" protocol "github.com/tliron/glsp/protocol_3_16" @@ -25,8 +24,6 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa cursor := params.Position.Character targetField := entry.GetFieldAtPosition(cursor - 1) - println("cursor at", cursor, "target field", targetField) - switch targetField { case FstabFieldSpec: value, cursor := GetFieldSafely(entry.Fields.Spec, cursor) @@ -43,9 +40,7 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa cursor, ), nil case FstabFieldFileSystemType: - println(fmt.Sprintf("file system type: %s", entry.Fields.FilesystemType)) value, cursor := GetFieldSafely(entry.Fields.FilesystemType, cursor) - println("CURSOR", cursor) return fstabdocumentation.FileSystemTypeField.FetchCompletions( value, @@ -64,10 +59,12 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa value, cursor := GetFieldSafely(entry.Fields.Options, cursor) - return optionsField.FetchCompletions( + completions := optionsField.FetchCompletions( value, cursor, - ), nil + ) + + return completions, nil case FstabFieldFreq: value, cursor := GetFieldSafely(entry.Fields.Freq, cursor) diff --git a/handlers/openssh/text-document-did-open.go b/handlers/openssh/text-document-did-open.go index 652cfba..7c533e3 100644 --- a/handlers/openssh/text-document-did-open.go +++ b/handlers/openssh/text-document-did-open.go @@ -11,8 +11,6 @@ import ( func TextDocumentDidOpen(context *glsp.Context, params *protocol.DidOpenTextDocumentParams) error { readBytes, err := os.ReadFile(params.TextDocument.URI[len("file://"):]) - println("opened i la language eta", params.TextDocument.LanguageID) - if err != nil { return err }