lua

package
v0.0.0-...-e67fd50 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package lua provides Lua scripting engine integration

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTimeout

func WithTimeout[T any](L *glua.LState, d time.Duration, fn func() (T, error)) (T, error)

WithTimeout executes a function with a timeout

Types

type Engine

type Engine struct {
	L *glua.LState
	// contains filtered or unexported fields
}

Engine is a Lua scripting engine using gopher-lua (enabled with build tag 'lua')

func NewEngine

func NewEngine() *Engine

NewEngine creates a new Lua scripting engine instance

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) Emit

func (e *Engine) Emit(event string, ctx any) error

Emit triggers event handlers registered via dk.hooks.on()

func (*Engine) Init

func (e *Engine) Init() error

Init initializes the Lua engine and sets up the execution environment

func (*Engine) LanguagesForPath

func (e *Engine) LanguagesForPath(path string) []string

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

func (e *Engine) LoadLanguages(langs []string) error

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) RunFile

func (e *Engine) RunFile(path string) error

RunFile loads and executes a Lua script file

func (*Engine) RunFileWithCtx

func (e *Engine) RunFileWithCtx(path string, ctx any) error

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

func (e *Engine) SetExtensionsMap(m map[string][]string)

SetExtensionsMap stores extension-to-language mapping used by higher-level file hook context creation.

type Transformer

type Transformer struct {
	L *glua.LState
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

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