-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into pr/saidelike/2131
- Loading branch information
Showing
144 changed files
with
3,553 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"trailingComma": "all" | ||
"trailingComma": "all", | ||
"plugins": ["prettier-plugin-tailwindcss"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
tags: [enhancement] | ||
pullRequest: 1962 | ||
--- | ||
|
||
- Add support for the Lua programming language |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
tags: [enhancement] | ||
pullRequest: 2254 | ||
--- | ||
|
||
- Added every/spread ordinal/relative modifier. Turns relative and ordinal range modifiers into multiple target selections instead of contiguous range. | ||
|
||
- `"take every two tokens"` selects two tokens as separate selections | ||
- `"pre every first two lines"` puts a cursor before each of first two lines in block (results in multiple cursors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
tags: [enhancement] | ||
pullRequest: 2235 | ||
--- | ||
|
||
- Fall back to text-based Talon actions when editor is not focused. This allows you to say things like "take token", "bring air", etc, when in the terminal, search bar, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
from typing import Callable | ||
|
||
from talon import actions | ||
|
||
from .versions import COMMAND_VERSION | ||
|
||
# This ensures that we remember to update fallback if the response payload changes | ||
assert COMMAND_VERSION == 7 | ||
|
||
action_callbacks = { | ||
"getText": lambda: [actions.edit.selected_text()], | ||
"setSelection": actions.skip, | ||
"setSelectionBefore": actions.edit.left, | ||
"setSelectionAfter": actions.edit.right, | ||
"copyToClipboard": actions.edit.copy, | ||
"cutToClipboard": actions.edit.cut, | ||
"pasteFromClipboard": actions.edit.paste, | ||
"clearAndSetSelection": actions.edit.delete, | ||
"remove": actions.edit.delete, | ||
"editNewLineBefore": actions.edit.line_insert_up, | ||
"editNewLineAfter": actions.edit.line_insert_down, | ||
} | ||
|
||
modifier_callbacks = { | ||
"extendThroughStartOf.line": actions.user.select_line_start, | ||
"extendThroughEndOf.line": actions.user.select_line_end, | ||
"containingScope.document": actions.edit.select_all, | ||
"containingScope.paragraph": actions.edit.select_paragraph, | ||
"containingScope.line": actions.edit.select_line, | ||
"containingScope.token": actions.edit.select_word, | ||
} | ||
|
||
|
||
def call_as_function(callee: str): | ||
wrap_with_paired_delimiter(f"{callee}(", ")") | ||
|
||
|
||
def wrap_with_paired_delimiter(left: str, right: str): | ||
selected = actions.edit.selected_text() | ||
actions.insert(f"{left}{selected}{right}") | ||
for _ in right: | ||
actions.edit.left() | ||
|
||
|
||
def containing_token_if_empty(): | ||
if actions.edit.selected_text() == "": | ||
actions.edit.select_word() | ||
|
||
|
||
def perform_fallback(fallback: dict): | ||
try: | ||
modifier_callbacks = get_modifier_callbacks(fallback) | ||
action_callback = get_action_callback(fallback) | ||
for callback in reversed(modifier_callbacks): | ||
callback() | ||
return action_callback() | ||
except ValueError as ex: | ||
actions.app.notify(str(ex)) | ||
|
||
|
||
def get_action_callback(fallback: dict) -> Callable: | ||
action = fallback["action"] | ||
|
||
if action in action_callbacks: | ||
return action_callbacks[action] | ||
|
||
match action: | ||
case "insert": | ||
return lambda: actions.insert(fallback["text"]) | ||
case "callAsFunction": | ||
return lambda: call_as_function(fallback["callee"]) | ||
case "wrapWithPairedDelimiter": | ||
return lambda: wrap_with_paired_delimiter( | ||
fallback["left"], fallback["right"] | ||
) | ||
|
||
raise ValueError(f"Unknown Cursorless fallback action: {action}") | ||
|
||
|
||
def get_modifier_callbacks(fallback: dict) -> list[Callable]: | ||
return [get_modifier_callback(modifier) for modifier in fallback["modifiers"]] | ||
|
||
|
||
def get_modifier_callback(modifier: dict) -> Callable: | ||
modifier_type = modifier["type"] | ||
|
||
match modifier_type: | ||
case "containingTokenIfEmpty": | ||
return containing_token_if_empty | ||
case "containingScope": | ||
scope_type_type = modifier["scopeType"]["type"] | ||
return get_simple_modifier_callback(f"{modifier_type}.{scope_type_type}") | ||
case "extendThroughStartOf": | ||
if "modifiers" not in modifier: | ||
return get_simple_modifier_callback(f"{modifier_type}.line") | ||
case "extendThroughEndOf": | ||
if "modifiers" not in modifier: | ||
return get_simple_modifier_callback(f"{modifier_type}.line") | ||
|
||
raise ValueError(f"Unknown Cursorless fallback modifier: {modifier_type}") | ||
|
||
|
||
def get_simple_modifier_callback(key: str) -> Callable: | ||
try: | ||
return modifier_callbacks[key] | ||
except KeyError: | ||
raise ValueError(f"Unknown Cursorless fallback modifier: {key}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.