Documentation
¶
Index ¶
- func ValidateToml(text string) error
- type Key
- type Position
- type Range
- type Table
- type TomlContext
- type TomlDocument
- func NewTomlDocument() *TomlDocument
- func ParseLoose(text string) *TomlDocument
- func ParseLooseWithCursor(text string, cursorPos Position) *TomlDocument
- func ParseStrict(text string) (*TomlDocument, error)
- func ParseToml(text string) *TomlDocument
- func ParseTomlWithCursor(text string, cursorPos Position) *TomlDocument
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateToml ¶
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 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