Documentation
¶
Overview ¶
Package lua provides Lua scripting engine integration
Index ¶
- func WithTimeout[T any](L *glua.LState, d time.Duration, fn func() (T, error)) (T, error)
- type Engine
- func (e *Engine) ClearForTests()
- func (e *Engine) CollectVariableTransformers() []contracts.VariableTransformer
- func (e *Engine) Emit(event string, ctx any) error
- func (e *Engine) Init() error
- func (e *Engine) LanguagesForPath(path string) []string
- func (e *Engine) LoadLanguages(langs []string) error
- func (e *Engine) ResetForTests()
- func (e *Engine) RunFile(path string) error
- func (e *Engine) RunFileWithCtx(path string, ctx any) error
- func (e *Engine) SetExtensionsMap(m map[string][]string)
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Engine ¶
Engine is a Lua scripting engine using gopher-lua (enabled with build tag 'lua')
func (*Engine) ClearForTests ¶
func (e *Engine) ClearForTests()
ClearForTests resets mutable state used by tests (transformers and maps)
func (*Engine) CollectVariableTransformers ¶
func (e *Engine) CollectVariableTransformers() []contracts.VariableTransformer
CollectVariableTransformers returns Go adapters for all registered Lua transformers
func (*Engine) LanguagesForPath ¶
LanguagesForPath resolves the effective languages for a given file path. Always includes "common" first. If a mapping is configured, applies specific globs first then '*' fallback; otherwise uses all loaded packs.
func (*Engine) LoadLanguages ¶
LoadLanguages loads the given language packs in order (in addition to 'common').
func (*Engine) ResetForTests ¶
func (e *Engine) ResetForTests()
ResetForTests fully resets the engine for testing (including Lua state)
func (*Engine) RunFileWithCtx ¶
RunFileWithCtx loads a Lua script and, if it returns a function, calls it with dk and a context available under dk.run
func (*Engine) SetExtensionsMap ¶
SetExtensionsMap stores extension-to-language mapping used by higher-level file hook context creation.
type Transformer ¶
Transformer adapts a Lua transform function to Go VariableTransformer
func (*Transformer) GetTokenName ¶
func (lt *Transformer) GetTokenName() string
GetTokenName returns the token name for this transformer
func (*Transformer) Transform ¶
func (lt *Transformer) Transform(className string) string
Transform applies the Lua transformation function to a class name