toml

package
v0.19.771 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateToml

func ValidateToml(text string) error

ValidateToml validates TOML syntax using strict parser Returns nil if valid, error if invalid Use this for validation/diagnostics, not for position-based features

Types

type Key

type Key struct {
	Name   string   // e.g. "directory"
	Path   []string // fully qualified path e.g. ["connected_repo", "directory"]
	Prefix string   // prefix typed so far, if partial
	Range  Range    // line/column of the key occurrence
	Value  any      // parsed value if available
}

Key represents a TOML key (complete or partial)

type Position

type Position struct {
	Line      int
	Character int
}

Position represents a line/column location in a TOML document

type Range

type Range struct {
	Start Position
	End   Position
}

Range represents a span in a TOML document

type Table

type Table struct {
	Name  string   // e.g. "connected_repo"
	Path  []string // split path for nested tables e.g. ["parent", "child"]
	Range Range    // line/column of the table header
}

Table represents a TOML table or array-of-tables

type TomlContext

type TomlContext struct {
	CurrentTable string   // current table name
	KeyOnLine    string   // key on this line if any
	Prefix       string   // prefix before cursor (for completion)
	KeyPath      []string // fully qualified key path
}

TomlContext represents the context at a specific position in a TOML document

type TomlDocument

type TomlDocument struct {
	Tables       []Table
	Keys         []Key
	CurrentTable string         // current table context
	Values       map[string]any // map of key-path → value
}

TomlDocument represents a parsed TOML document

func NewTomlDocument

func NewTomlDocument() *TomlDocument

NewTomlDocument creates a new empty TomlDocument

func ParseLoose

func ParseLoose(text string) *TomlDocument

ParseLoose parses TOML using a text-based scanner that tolerates invalid input This mode never returns an error and works on incomplete TOML

func ParseLooseWithCursor

func ParseLooseWithCursor(text string, cursorPos Position) *TomlDocument

ParseLooseWithCursor parses TOML and detects the prefix at a specific cursor position

func ParseStrict

func ParseStrict(text string) (*TomlDocument, error)

ParseStrict attempts to parse TOML using strict mode Returns a TomlDocument and an error if parsing fails

func ParseToml

func ParseToml(text string) *TomlDocument

ParseToml parses TOML text using loose parsing for LSP Always uses loose parsing to preserve position information Never returns an error - the LSP must remain operational for all inputs

func ParseTomlWithCursor

func ParseTomlWithCursor(text string, cursorPos Position) *TomlDocument

ParseTomlWithCursor parses TOML and provides cursor context Uses loose parsing with cursor-aware position tracking

func (*TomlDocument) ContextAt

func (doc *TomlDocument) ContextAt(pos Position) TomlContext

ContextAt returns the TOML context at a specific position

func (*TomlDocument) SchemaPath

func (doc *TomlDocument) SchemaPath(keyPath []string) []string

SchemaPath returns the schema path for a given key path

func (*TomlDocument) TableSchemaPath

func (doc *TomlDocument) TableSchemaPath(tableName string) []string

TableSchemaPath returns the schema path for a table

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL