Skip to content

Commit a390a19

Browse files
Merge branch 'main' into collectionItemScopeProvider
2 parents 1ae5c32 + b65ac4e commit a390a19

18 files changed

+111
-51
lines changed

cursorless-talon/src/apps/vscode_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def vscode_settings_path() -> Path:
9999
xdg_config_home / "Code/User/settings.json",
100100
xdg_config_home / "VSCodium/User/settings.json",
101101
xdg_config_home / "Code - OSS/User/settings.json",
102+
xdg_config_home / "Cursor/User/settings.json",
102103
flatpak_apps / "com.visualstudio.code/config/Code/User/settings.json",
103104
flatpak_apps / "com.vscodium.codium/config/VSCodium/User/settings.json",
104105
flatpak_apps
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from talon import app, registry
2+
3+
required_captures = [
4+
"number_small",
5+
"user.any_alphanumeric_key",
6+
"user.formatters",
7+
"user.ordinals_small",
8+
]
9+
10+
required_actions = [
11+
"user.homophones_get",
12+
"user.reformat_text",
13+
]
14+
15+
16+
def on_ready():
17+
missing_captures = [
18+
capture for capture in required_captures if capture not in registry.captures
19+
]
20+
missing_actions = [
21+
action for action in required_actions if action not in registry.actions
22+
]
23+
errors = []
24+
if missing_captures:
25+
errors.append(f"Missing captures: {', '.join(missing_captures)}")
26+
if missing_actions:
27+
errors.append(f"Missing actions: {', '.join(missing_actions)}")
28+
if errors:
29+
print("\n".join(errors))
30+
app.notify(
31+
"Please install the community repository",
32+
body="https://github.com/talonhub/community",
33+
)
34+
35+
36+
app.register("ready", on_ready)

cursorless-talon/src/modifiers/ordinal_scope.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313
@mod.capture(
1414
rule="<user.ordinals_small> | [<user.ordinals_small>] {user.cursorless_last_modifier}"
1515
)
16-
def ordinal_or_last(m) -> int:
16+
def cursorless_ordinal_or_last(m) -> int:
1717
"""An ordinal or the word 'last'"""
1818
if m[-1] == "last":
1919
return -getattr(m, "ordinals_small", 1)
2020
return m.ordinals_small - 1
2121

2222

2323
@mod.capture(
24-
rule="<user.ordinal_or_last> [<user.cursorless_range_connective> <user.ordinal_or_last>] <user.cursorless_scope_type>"
24+
rule="<user.cursorless_ordinal_or_last> [<user.cursorless_range_connective> <user.cursorless_ordinal_or_last>] <user.cursorless_scope_type>"
2525
)
2626
def cursorless_ordinal_range(m) -> dict[str, Any]:
2727
"""Ordinal range"""
2828
anchor = create_ordinal_scope_modifier(
29-
m.cursorless_scope_type, m.ordinal_or_last_list[0]
29+
m.cursorless_scope_type, m.cursorless_ordinal_or_last_list[0]
3030
)
31-
if len(m.ordinal_or_last_list) > 1:
31+
if len(m.cursorless_ordinal_or_last_list) > 1:
3232
active = create_ordinal_scope_modifier(
33-
m.cursorless_scope_type, m.ordinal_or_last_list[1]
33+
m.cursorless_scope_type, m.cursorless_ordinal_or_last_list[1]
3434
)
3535
range_connective: RangeConnective = m.cursorless_range_connective
3636
return {

cursorless-talon/src/modifiers/simple_scope_modifier.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
# This is a private setting and should not be used by non Cursorless developers
1717
mod.setting(
1818
"private_cursorless_use_preferred_scope",
19-
bool,
19+
type=bool,
20+
default=False,
2021
desc="Use preferred scope instead of containing scope for all scopes by default (EXPERIMENTAL)",
2122
)
2223

@@ -42,7 +43,7 @@ def cursorless_simple_scope_modifier(m) -> dict[str, Any]:
4243
"ancestorIndex": 1,
4344
}
4445

45-
if settings.get("user.private_cursorless_use_preferred_scope", False):
46+
if settings.get("user.private_cursorless_use_preferred_scope"):
4647
return {
4748
"type": "preferredScope",
4849
"scopeType": m.cursorless_scope_type,

dont_clone_monorepo.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
This file exists in our monorepo so that if someone accidentally clones this monorepo
3+
into their talon folder instead of cursorless-talon, they'll get a helpful error popup
4+
"""
5+
6+
from talon import app
7+
8+
9+
def on_ready():
10+
app.notify(
11+
"Whoops! You cloned our monorepo instead of cursorless-talon",
12+
"Please remove cursorless and clone cursorless-talon instead:",
13+
"https://github.com/cursorless-dev/cursorless-talon",
14+
)
15+
16+
17+
app.register("ready", on_ready)

packages/cursorless-engine/src/processTargets/modifiers/ContainingScopeStage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class ContainingScopeStage implements ModifierStage {
3434
run(target: Target): Target[] {
3535
const { scopeType, ancestorIndex = 0 } = this.modifier;
3636

37-
const scopeHandler = this.scopeHandlerFactory.create(
37+
const scopeHandler = this.scopeHandlerFactory.maybeCreate(
3838
scopeType,
3939
target.editor.document.languageId,
4040
);

packages/cursorless-engine/src/processTargets/modifiers/EveryScopeStage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class EveryScopeStage implements ModifierStage {
3939
const { scopeType } = this.modifier;
4040
const { editor, isReversed } = target;
4141

42-
const scopeHandler = this.scopeHandlerFactory.create(
42+
const scopeHandler = this.scopeHandlerFactory.maybeCreate(
4343
scopeType,
4444
editor.document.languageId,
4545
);
@@ -101,7 +101,7 @@ export class EveryScopeStage implements ModifierStage {
101101
scopeHandlerFactory: ScopeHandlerFactory,
102102
target: Target,
103103
): Range[] {
104-
const iterationScopeHandler = scopeHandlerFactory.create(
104+
const iterationScopeHandler = scopeHandlerFactory.maybeCreate(
105105
scopeHandler.iterationScopeType,
106106
target.editor.document.languageId,
107107
);

packages/cursorless-engine/src/processTargets/modifiers/PreferredScopeStage.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ export class PreferredScopeStage implements ModifierStage {
4646
target.editor.document.languageId,
4747
);
4848

49-
if (scopeHandler == null) {
50-
throw Error(`Couldn't create scope handler for: ${scopeType.type}`);
51-
}
52-
5349
const closestTargets = getClosestScopeTargets(target, scopeHandler);
5450

5551
if (closestTargets == null) {

packages/cursorless-engine/src/processTargets/modifiers/RelativeScopeStage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class RelativeScopeStage implements ModifierStage {
3131
) {}
3232

3333
run(target: Target): Target[] {
34-
const scopeHandler = this.scopeHandlerFactory.create(
34+
const scopeHandler = this.scopeHandlerFactory.maybeCreate(
3535
this.modifier.scopeType,
3636
target.editor.document.languageId,
3737
);

packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/BoundedScopeHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ abstract class BoundedBaseScopeHandler extends BaseScopeHandler {
3535
this.targetScopeHandler = this.scopeHandlerFactory.create(
3636
this.targetScopeType,
3737
this.languageId,
38-
)!;
38+
);
3939
this.surroundingPairInteriorScopeHandler = this.scopeHandlerFactory.create(
4040
{
4141
type: "surroundingPairInterior",
4242
delimiter: "any",
4343
},
4444
this.languageId,
45-
)!;
45+
);
4646
}
4747

4848
get iterationScopeType(): ScopeType {

0 commit comments

Comments
 (0)