Documentation
¶
Overview ¶
Package formatter provides source code formatting for ELPS lisp files. It uses the ELPS parser in format-preserving mode to parse source code into an annotated AST, then walks the tree to produce formatted output.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRules ¶
func DefaultRules() map[string]*IndentRule
DefaultRules returns the default indent rules table.
Types ¶
type Config ¶
type Config struct {
IndentSize int // spaces per indent level (default: 2)
MaxBlankLines int // max consecutive blank lines (default: 1)
Rules map[string]*IndentRule // form name -> rule
}
Config holds formatting configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default formatting configuration.
func (*Config) RuleFor ¶
func (c *Config) RuleFor(name string) *IndentRule
RuleFor returns the indent rule for the given form name. If no specific rule exists, returns the default first-arg alignment rule. Forms starting with "def" get defun-style indent (2 header args + body), following the common Lisp convention for definition forms.
type IndentRule ¶
type IndentRule struct {
Style IndentStyle
HeaderArgs int // for IndentSpecial: args before the "body"
}
IndentRule specifies the indentation behavior for a particular form.
type IndentStyle ¶
type IndentStyle int
IndentStyle determines how arguments in an s-expression are indented.
const ( // IndentAlign indents subsequent lines to align with the first argument. IndentAlign IndentStyle = iota // IndentBody indents all subforms at bracket column + indent size. IndentBody // IndentSpecial indents N header args aligned, rest at bracket + indent size. IndentSpecial )