-
-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathcontaining_scope.py
More file actions
97 lines (81 loc) · 2.59 KB
/
Copy pathcontaining_scope.py
File metadata and controls
97 lines (81 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from typing import Any
from talon import Module, app
from ..csv_overrides import init_csv_and_watch_changes
mod = Module()
mod.list("cursorless_scope_type", desc="Supported scope types")
# NOTE: Please do not change these dicts. Use the CSVs for customization.
# See https://www.cursorless.org/docs/user/customization/
scope_types = {
"arg": "argumentOrParameter",
"attribute": "attribute",
"call": "functionCall",
"class name": "className",
"class": "class",
"comment": "comment",
"funk name": "functionName",
"funk": "namedFunction",
"if state": "ifStatement",
"item": "collectionItem",
"key": "collectionKey",
"lambda": "anonymousFunction",
"list": "list",
"map": "map",
"name": "name",
"regex": "regularExpression",
"section": "section",
"-one section": "sectionLevelOne",
"-two section": "sectionLevelTwo",
"-three section": "sectionLevelThree",
"-four section": "sectionLevelFour",
"-five section": "sectionLevelFive",
"-six section": "sectionLevelSix",
"selector": "selector",
"state": "statement",
"string": "string",
"type": "type",
"value": "value",
"condition": "condition",
# XML, JSX
"element": "xmlElement",
"tags": "xmlBothTags",
"start tag": "xmlStartTag",
"end tag": "xmlEndTag",
# Text-based scope types
"block": "paragraph",
"cell": "notebookCell",
"file": "document",
"line": "line",
"paint": "nonWhitespaceSequence",
"link": "url",
"token": "token",
}
@mod.capture(rule="[every] {user.cursorless_scope_type}")
def cursorless_containing_scope(m) -> dict[str, Any]:
"""Expand to containing scope"""
return {
"type": "everyScope" if m[0] == "every" else "containingScope",
"scopeType": {
"type": m.cursorless_scope_type,
},
}
# NOTE: Please do not change these dicts. Use the CSVs for customization.
# See https://www.cursorless.org/docs/user/customization/
subtoken_scope_types = {
"word": "word",
"char": "character",
}
# NOTE: Please do not change these dicts. Use the CSVs for customization.
# See https://www.cursorless.org/docs/user/customization/
# NB: This is a hack until we support having inside and outside on arbitrary
# scope types
surrounding_pair_scope_types = {
"string": "string",
}
default_values = {
"scope_type": scope_types,
"subtoken_scope_type": subtoken_scope_types,
"surrounding_pair_scope_type": surrounding_pair_scope_types,
}
def on_ready():
init_csv_and_watch_changes("modifier_scope_types", default_values)
app.register("ready", on_ready)