Skip to content

kotlin

This directory provides support for the Kotlin programming language within the Talon voice coding environment. It integrates Kotlin-specific keywords, types, operators, and formatting conventions into the unified Talon programming interface.

How it Works

The Kotlin support is split into two core files:

  1. kotlin.py: Implements the programmatic behavior, context matching, lists (keywords and types), and actions.
  2. kotlin.talon: Activates standard programming capabilities (tags) and configures naming conventions (settings) when editing a Kotlin file.

File Breakdown

kotlin.py

This Python script is activated when the active file's language is set to kotlin. It performs several key tasks:

  • Keyword and Type Lists: Populates Talon's global lists (user.code_keyword and user.code_type) with Kotlin-specific vocabulary (such as val, var, lateinit, companion object, and standard types like Int, Boolean, and Nothing).
  • Operators Configuration: Defines standard mathematical, assignment, array, and bitwise operators using a structured Operators class. It also configures Kotlin's lambda symbol (->).
  • Custom Action Implementations: Overrides standard Talon coding actions to match Kotlin syntax:
    • Inserts this for self-referencing.
    • Provides specialized helper functions for null checks (== null, != null).
    • Dynamically builds function definitions (e.g., fun myFunction() or private fun myFunction()) using the appropriate casing formatters.

kotlin.talon

This file configures the voice environment when working inside Kotlin files:

  • Enables Language Capabilities: Activates standard Talon tags that grant access to generalized voice commands for object-oriented programming, imperative control flow, comments, data structures, and mathematical operators.
  • Language-Specific Formatting: Sets the variable and function formatting settings. In Kotlin, public, private, and protected functions and variables all default to PRIVATE_CAMEL_CASE (e.g., camelCaseName).