ruby
This directory provides support for the Ruby programming language in Talon. It defines standard operators, configures formatting conventions, and registers syntax structures and voice commands tailored specifically for writing Ruby code.
How it Works
The Ruby language support is split into two core files that work together to configure Talon when editing Ruby files.
Python Backend Implementation
The ruby.py file handles the programmatic implementation of Ruby's syntax rules. It defines a context that activates when the active file's language is set to ruby.
Key features implemented in ruby.py include:
- Operator Definitions: Implements the
Operatorsclass, mapping abstract programming concepts (like assignments, mathematical operations, bitwise actions, lambdas, and subscripts) to Ruby-specific operators. This includes Ruby's conditional assignment operator||=. - Booleans and Nulls: Maps standard actions to insert
true,false, andnil. It also overrides null checking logic to output.nil?for null checks and.present?(commonly used in Rails) for non-null checks. - Function Insertion: Overrides
code_default_functionto automatically format and insert Ruby method definitions (def method_name) using the configured formatter settings.
Talon Command Configuration
The ruby.talon file defines the voice command interface and configures style rules for Ruby files.
Key definitions in ruby.talon include:
- Syntax Tag Activation: Enables standard programming paradigms such as
user.code_imperativeanduser.code_object_oriented, along with specific operator tags likeuser.code_operators_lambdaanduser.code_operators_math. - Formatting Constraints: Enforces
SNAKE_CASEas the default formatter for all private, public, and protected functions and variables, matching standard Ruby style guidelines. - Voice Commands:
state end,state begin,state rescue, andstate modulequickly insert control flow and structural keywords.args pipeinserts block argument wrappers (| |).instance <user.text>formats the dictation as snake case and prepends@to easily output instance variables.