lua
This directory provides Talon voice-coding support for the Lua programming language. It defines standard programming patterns, language keywords, built-in functions, library structures, and style rules tailored for writing Lua scripts efficiently.
Core Language Support
The Python file lua.py implements the backend behavior for Lua context matching, environment configuration, and code formatting:
- Version-Sensitive Operators: It registers a
lua_versionsetting (defaulting to5.1). Based on this version, bitwise operators will adjust dynamically. For version5.3and higher, it outputs modern native operators (such as&or~); for older versions, it falls back to library-based calls likebit.band()andbit.xor(). - Action Implementations: It overrides standard user actions to match Lua's syntax requirements, such as block comments (
--[[ ... --]]), boolean values (trueandfalse), null representations (nil), and localized functions (local function name() ... end). - Libraries and Objects: Defines common Lua libraries (like
utf8,table,math,os, andsocket) to facilitate quick syntax construction.
Syntax Rules and Spoken Commands
The grammar and specific formatting controls are declared in lua.talon. When a file with the .lua extension is active, this file automatically loads and configures the editor environment:
- Standard Styling: Configures standard variable and function formatters to use
SNAKE_CASEas is common in the Lua community. - Tag Activation: Integrates Lua with general community programming tags, including imperative code structures, math operations, and key-value pairings.
- Custom Constructs: Provides spoken triggers for fast syntax assembly. For example:
- "state local variable" inserts a local variable formatted in snake case.
- "method <text>" formats a colon-based method call on an object (e.g.,
:gsub()). - "require <library>" automates inserting import/require statement snippets.
- "state return true/false" inserts instant return conditions.
Vocabulary and Auto-completions
To ensure you can speak standard language constructs and built-in library methods easily, the environment uses list mapping files:
- code_keyword.talon-list and code_keyword_unprefixed.talon-list register native keywords (e.g.,
elseif,repeat,until,local,function) to be recognized directly while typing or dictating. - code_common_function.talon-list hooks up spoken forms for standard library features, allowing you to instantly type utilities like
ipairs,table.insert,string.gsub,os.execute, and formatting commands likestring.format.
Code Formatter Integration
If you use StyLua to maintain clean styling, enabling the user.stylua tag will activate the commands inside stylua.talon. This allows you to speak voice commands to wrap code lines or code blocks with native StyLua ignore comments:
-- stylua: ignore-- stylua: ignore start/-- stylua: ignore end