r
The community/lang/r
directory contains the Talon files for enabling R language support.
The file r.py
defines the core functionality for R support in Talon. It sets the context for R code (code.language: r
) and defines several lists:
user.code_common_function
: This list contains a large number of common R functions, grouped by package (base R, dplyr, ggplot2, purrr, stringr, tidyr, readr/readxl, Shiny) for easy access. These are used to insert code snippets using voice commands.user.code_libraries
: This list contains a list of R libraries and their associated names.user.code_parameter_name
: This list contains common parameter names in R.- An
UserActions
class provides methods that implement common code insertion and manipulation actions, such as inserting operators, control flow statements, and comments, or defining functions.
The r.talon
file contains Talon voice commands and settings specific to R:
- It sets tags for R code, including
user.code_imperative
,user.code_block_c_like
,user.code_comment_line
,user.code_data_bool
,user.code_data_null
,user.code_functions
,user.code_functions_common
,user.code_libraries
,user.code_operators_assignment
,user.code_operators_bitwise
, anduser.code_operators_math
. These tags activate certain functionalities or voice commands from other files, such as how to handle comments or which mathematical operators are available. - It sets formatting rules for functions and variables using settings like
user.code_private_function_formatter = "SNAKE_CASE"
. - It defines voice commands, including
(op | is) in
, which inserts the R membership operator%in%
. - It defines a voice command for toggling libraries using
toggle library: user.code_toggle_libraries()
. - The voice command
library <user.code_libraries>
inserts a library name into alibrary()
call. - The command
(chain | pipe that)
inserts the pipe operator%>%
to chain operations. - The command
state na
inserts theNA
value - The command
^function define <user.text>$
defines a private function. - The command
named arg {user.code_parameter_name}
inserts a named argument into a function call.
These two files work together to provide a robust R development experience with Talon. The Python file provides the underlying logic and list of available functions and libraries, while the Talon file provides the voice commands.