fix: Overall improvements

This commit is contained in:
Myzel394 2024-08-10 17:23:58 +02:00
parent 1a909a6d2d
commit 04fe0d2dc8
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
3 changed files with 23 additions and 1 deletions

View File

@ -114,6 +114,7 @@ func (v KeyEnumAssignmentValue) FetchEnumCompletions() []protocol.CompletionItem
kind := protocol.CompletionItemKindField kind := protocol.CompletionItemKindField
val := v.Values[enumKey] val := v.Values[enumKey]
description := val.GetTypeDescription() description := val.GetTypeDescription()
insertText := enumKey.InsertText + v.Separator
var documentation string var documentation string
@ -125,6 +126,7 @@ func (v KeyEnumAssignmentValue) FetchEnumCompletions() []protocol.CompletionItem
completions = append(completions, protocol.CompletionItem{ completions = append(completions, protocol.CompletionItem{
Label: enumKey.InsertText, Label: enumKey.InsertText,
InsertText: &insertText,
InsertTextFormat: &textFormat, InsertTextFormat: &textFormat,
Kind: &kind, Kind: &kind,
Documentation: documentation, Documentation: documentation,

View File

@ -211,6 +211,11 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error {
case 6: case 6:
value := fields[5] value := fields[5]
start := uint32(strings.Index(line, value)) start := uint32(strings.Index(line, value))
if start == 0 {
start = uint32(len(line))
}
pass = &Field{ pass = &Field{
Value: fields[5], Value: fields[5],
Start: start, Start: start,
@ -221,6 +226,10 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error {
value := fields[4] value := fields[4]
start := uint32(strings.Index(line, value)) start := uint32(strings.Index(line, value))
if start == 0 {
start = uint32(len(line))
}
freq = &Field{ freq = &Field{
Value: value, Value: value,
Start: start, Start: start,
@ -231,6 +240,10 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error {
value := fields[3] value := fields[3]
start := uint32(strings.Index(line, value)) start := uint32(strings.Index(line, value))
if start == 0 {
start = uint32(len(line))
}
options = &Field{ options = &Field{
Value: value, Value: value,
Start: start, Start: start,
@ -241,6 +254,10 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error {
value := fields[2] value := fields[2]
start := uint32(strings.Index(line, value)) start := uint32(strings.Index(line, value))
if start == 0 {
start = uint32(len(line))
}
filesystemType = &Field{ filesystemType = &Field{
Value: value, Value: value,
Start: start, Start: start,
@ -251,6 +268,10 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error {
value := fields[1] value := fields[1]
start := uint32(strings.Index(line, value)) start := uint32(strings.Index(line, value))
if start == 0 {
start = uint32(len(line))
}
mountPoint = &Field{ mountPoint = &Field{
Value: value, Value: value,
Start: start, Start: start,

View File

@ -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"