Skip to content

Commit 7b79f6d

Browse files
fidgetingbitspre-commit-ci-lite[bot]AndreasArvidsson
authored
Added support for Shell script language. (#2058)
## What Adds support for some next gen scopes to `shellscript` programming language. This is something I did recently while working on some bash scripts, but haven't had time to finish it off yet. ## Checklist - [x] Recorded tests for the new language - [x] Used `"change"` / `"clear"` instead of` "take"` for selection tests to make recorded tests easier to read - [x] Added a few specific tests that use `"chuck"` instead of `"change"` to test removal behaviour when it's interesting, especially: - [x] `"chuck arg"` with single argument in list - [x] `"chuck arg"` with multiple arguments in list - [x] `"chuck item"` with single argument in list - [x] `"chuck item"` with multiple arguments in list - [x] Added `@textFragment` captures. Usually you want to put these on comment and string nodes. This enables `"take round"` to work within comments and strings. - [ ] Added a test for `"change round"` inside a string, eg `"hello (there)"` - [-] Supported` "type"` both for type annotations (eg `foo: string`) and declarations (eg `interface Foo {}`) (and added tests for this behaviour 😊) - [ ] Supported` "item"` both for map pairs and list entries (with tests of course) ## Scope Support Legend: &check; Supported, &cross; Not supported, _ Not applicable | Supported | Tested | Term | Capture | Definition | Comment | | --------- | ------- | ---------------- | ----------------------------- | ------------------------------------------------------------------- | ------- | | &check; | &check; | `list` | `@list` | List type equivalent | - | | &check; | &check; | `inside list` | `@list.interior` | Inside of a list | - | | _ | _ | `map` | `@map` | Dictionary type equivalent | - | | _ | _ | `inside map` | `@map.interior` | Inside of a dictionary | - | | _ | _ | `key` | `@collectionKey` | Dictionary key equivalent | - | | &check; | &check; | `funk` | `@namedFunction` | A named function declaration | - | | &check; | &check; | `inside funk` | `@namedFunction.interior` | The inside of a lambda declaration | - | | &check; | &check; | `funk name` | `@functionName` | Name of declared function | - | | _ | _ | `lambda` | `@anonymousFunction` | A lambda declaration | - | | _ | _ | `inside lambda` | `@anonymousFunction.interior` | The inside of a lambda declaration | - | | &check; | &check; | `name` | `@name` | Variable name | - | | &check; | &check; | `value` | `@value` | Right-hand-side value of an assignment | - | | _ | _ | `value` | `@value` | Value returned from a function | - | | | | `value` | `@value` | Value of a key-value pair | - | | &check; | &check; | `state` | `@statement` | Any single coded statement | - | | &check; | &check; | `if state` | `@ifStatement` | An if conditional block | - | | &check; | &check; | `condition` | `@condition` | Condition of an if block | - | | &check; | | `condition` | `@condition` | Condition of a while loop | - | | &check; | | `condition` | `@condition` | Condition of a do while style loop | - | | &check; | | `condition` | `@condition` | Condition of a for loop | - | | &check; | | `condition` | `@condition` | Condition of a switch case | - | | _ | _ | `condition` | `@condition` | Condition of a ternary expression | - | | &check; | &check; | `branch` | `@branch` | The resulting code associated with af conditional expression | - | | &check; | &check; | `inside branch` | `@branch.interior` | The statements associated with the body of a conditional expression | - | | &check; | &check; | `comment` | `@comment` | Code comment | - | | _ | _ | `comment` | `@comment` | Multi-line code comment | - | | | | `inside comment` | `@comment.interior` | The inside of a code comment | - | | &check; | &check; | `string` | `@string` | Single line strings | - | | _ | _ | `string` | `@string` | Multi-line strings | | | &check; | &check; | - | `@textFragment` | Used to capture string-type nodes (strings and comments) | - | | &check; | &check; | `call` | `@functionCall` | A function call (not a function definition) | - | | &check; | &check; | `callee` | `@functionCallee` | Name of the function being called | - | | _ | _ | `arg` | `@argumentOrParameter` | Arguments to function definition | - | | &check; | &check; | `arg` | `@argumentOrParameter` | Arguments to function call | - | | &check; | &check; | `arg` | `@argumentOrParameter` | Interpolated variables in strings | - | | _ | _ | `class` | `@class` | Class or structure declaration | - | | _ | _ | `inside class` | `@class.interior` | The inside of a class declaration | - | | _ | _ | `class name` | `@className` | Name of class or structure declaration | - | | _ | _ | `type` | `@type` | Type declarations | - | | &check; | &check; | `regex` | `@regex` | Regular expression | - | --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Andreas Arvidsson <andreas.arvidsson87@gmail.com>
1 parent 4a5c27f commit 7b79f6d

155 files changed

Lines changed: 7885 additions & 94 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 2026
44

5+
- 2026-09-09: Added support for Shell script language. ([#2058](https://github.com/cursorless-dev/cursorless/pull/2058))
56
- 2026-09-02: Added documentation for learning resources. ([#3334](https://github.com/cursorless-dev/cursorless/pull/3334))
67
- 2026-09-02: Added reference documentation for community draft editor. ([#3333](https://github.com/cursorless-dev/cursorless/pull/3333))
78
- 2026-09-02: Added reference documentation for community alphabet and symbols. ([#3332](https://github.com/cursorless-dev/cursorless/pull/3332))

‎packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/interior.json‎

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4868,6 +4868,186 @@
48684868
}
48694869
]
48704870
},
4871+
{
4872+
"name": "scopes/shellscript/interior/interior.for",
4873+
"languageId": "shellscript",
4874+
"facet": "interior.for",
4875+
"code": "for ((foo = 0; foo < 2; foo++)); do :; done",
4876+
"scopes": [
4877+
{
4878+
"targets": [
4879+
{
4880+
"content": "0:36-0:38",
4881+
"removal": "0:35-0:39"
4882+
}
4883+
],
4884+
"domain": "0:35-0:39"
4885+
}
4886+
]
4887+
},
4888+
{
4889+
"name": "scopes/shellscript/interior/interior.foreach",
4890+
"languageId": "shellscript",
4891+
"facet": "interior.foreach",
4892+
"code": "for v in values; do :; done",
4893+
"scopes": [
4894+
{
4895+
"targets": [
4896+
{
4897+
"content": "0:20-0:22",
4898+
"removal": "0:19-0:23"
4899+
}
4900+
],
4901+
"domain": "0:19-0:23"
4902+
}
4903+
]
4904+
},
4905+
{
4906+
"name": "scopes/shellscript/interior/interior.function",
4907+
"languageId": "shellscript",
4908+
"facet": "interior.function",
4909+
"code": "foo() { }",
4910+
"scopes": [
4911+
{
4912+
"targets": [
4913+
{
4914+
"content": "0:7-0:8",
4915+
"removal": "0:7-0:8"
4916+
}
4917+
],
4918+
"domain": "0:7-0:8"
4919+
}
4920+
]
4921+
},
4922+
{
4923+
"name": "scopes/shellscript/interior/interior.function2",
4924+
"languageId": "shellscript",
4925+
"facet": "interior.function",
4926+
"code": "function foo { }",
4927+
"scopes": [
4928+
{
4929+
"targets": [
4930+
{
4931+
"content": "0:14-0:15",
4932+
"removal": "0:14-0:15"
4933+
}
4934+
],
4935+
"domain": "0:14-0:15"
4936+
}
4937+
]
4938+
},
4939+
{
4940+
"name": "scopes/shellscript/interior/interior.if",
4941+
"languageId": "shellscript",
4942+
"facet": "interior.if",
4943+
"code": "if true; then\n :\nelif false; then\n :\nelse\n :\nfi",
4944+
"scopes": [
4945+
{
4946+
"targets": [
4947+
{
4948+
"content": "1:2-1:3",
4949+
"removal": "0:13-2:0"
4950+
}
4951+
],
4952+
"domain": "0:13-2:0"
4953+
},
4954+
{
4955+
"targets": [
4956+
{
4957+
"content": "3:2-3:3",
4958+
"removal": "2:16-4:0"
4959+
}
4960+
],
4961+
"domain": "2:16-4:0"
4962+
},
4963+
{
4964+
"targets": [
4965+
{
4966+
"content": "5:2-5:3",
4967+
"removal": "4:4-6:0"
4968+
}
4969+
],
4970+
"domain": "4:4-6:0"
4971+
}
4972+
]
4973+
},
4974+
{
4975+
"name": "scopes/shellscript/interior/interior.switch",
4976+
"languageId": "shellscript",
4977+
"facet": "interior.switch",
4978+
"code": "case $foo in esac",
4979+
"scopes": [
4980+
{
4981+
"targets": [
4982+
{
4983+
"content": "0:12-0:13",
4984+
"removal": "0:12-0:13"
4985+
}
4986+
],
4987+
"domain": "0:12-0:13"
4988+
}
4989+
]
4990+
},
4991+
{
4992+
"name": "scopes/shellscript/interior/interior.switchCase",
4993+
"languageId": "shellscript",
4994+
"facet": "interior.switchCase",
4995+
"code": "case $foo in\n 0) : ;;\nesac",
4996+
"scopes": [
4997+
{
4998+
"targets": [
4999+
{
5000+
"content": "1:2-1:9",
5001+
"removal": "0:12-2:0"
5002+
}
5003+
],
5004+
"domain": "0:12-2:0"
5005+
},
5006+
{
5007+
"targets": [
5008+
{
5009+
"content": "1:5-1:6",
5010+
"removal": "1:4-1:7"
5011+
}
5012+
],
5013+
"domain": "1:4-1:7"
5014+
}
5015+
]
5016+
},
5017+
{
5018+
"name": "scopes/shellscript/interior/interior.while",
5019+
"languageId": "shellscript",
5020+
"facet": "interior.while",
5021+
"code": "while foo; do :; done",
5022+
"scopes": [
5023+
{
5024+
"targets": [
5025+
{
5026+
"content": "0:14-0:16",
5027+
"removal": "0:13-0:17"
5028+
}
5029+
],
5030+
"domain": "0:13-0:17"
5031+
}
5032+
]
5033+
},
5034+
{
5035+
"name": "scopes/shellscript/interior/interior.while2",
5036+
"languageId": "shellscript",
5037+
"facet": "interior.while",
5038+
"code": "until foo; do :; done",
5039+
"scopes": [
5040+
{
5041+
"targets": [
5042+
{
5043+
"content": "0:14-0:16",
5044+
"removal": "0:13-0:17"
5045+
}
5046+
],
5047+
"domain": "0:13-0:17"
5048+
}
5049+
]
5050+
},
48715051
{
48725052
"name": "scopes/talon/interior.command",
48735053
"languageId": "talon",

‎packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/string.json‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,40 @@
594594
}
595595
]
596596
},
597+
{
598+
"name": "scopes/shellscript/string.multiLine",
599+
"languageId": "shellscript",
600+
"facet": "string.multiLine",
601+
"code": "\"Hello\nworld\"",
602+
"scopes": [
603+
{
604+
"targets": [
605+
{
606+
"content": "0:0-1:6",
607+
"removal": "0:0-1:6"
608+
}
609+
],
610+
"domain": "0:0-1:6"
611+
}
612+
]
613+
},
614+
{
615+
"name": "scopes/shellscript/string.singleLine",
616+
"languageId": "shellscript",
617+
"facet": "string.singleLine",
618+
"code": "\"Hello world\"",
619+
"scopes": [
620+
{
621+
"targets": [
622+
{
623+
"content": "0:0-0:13",
624+
"removal": "0:0-0:13"
625+
}
626+
],
627+
"domain": "0:0-0:13"
628+
}
629+
]
630+
},
597631
{
598632
"name": "scopes/talon/string.singleLine",
599633
"languageId": "talon",

‎packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/textFragment.json‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,57 @@
13601360
}
13611361
]
13621362
},
1363+
{
1364+
"name": "scopes/shellscript/textFragment.comment.line",
1365+
"languageId": "shellscript",
1366+
"facet": "textFragment.comment.line",
1367+
"code": "# Hello world",
1368+
"scopes": [
1369+
{
1370+
"targets": [
1371+
{
1372+
"content": "0:0-0:13",
1373+
"removal": "0:0-0:13"
1374+
}
1375+
],
1376+
"domain": "0:0-0:13"
1377+
}
1378+
]
1379+
},
1380+
{
1381+
"name": "scopes/shellscript/textFragment.string.multiLine",
1382+
"languageId": "shellscript",
1383+
"facet": "textFragment.string.multiLine",
1384+
"code": "\"Hello\nworld\"",
1385+
"scopes": [
1386+
{
1387+
"targets": [
1388+
{
1389+
"content": "0:1-1:5",
1390+
"removal": "0:1-1:5"
1391+
}
1392+
],
1393+
"domain": "0:1-1:5"
1394+
}
1395+
]
1396+
},
1397+
{
1398+
"name": "scopes/shellscript/textFragment.string.singleLine",
1399+
"languageId": "shellscript",
1400+
"facet": "textFragment.string.singleLine",
1401+
"code": "\"Hello world\"",
1402+
"scopes": [
1403+
{
1404+
"targets": [
1405+
{
1406+
"content": "0:1-0:12",
1407+
"removal": "0:1-0:12"
1408+
}
1409+
],
1410+
"domain": "0:1-0:12"
1411+
}
1412+
]
1413+
},
13631414
{
13641415
"name": "scopes/talon/textFragment.comment.line",
13651416
"languageId": "talon",

‎packages/app-web-docs/src/docs/contributing/private-scopes/interior.mdx‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ The following are internal scopes. They are not intended for user interaction or
295295

296296
<ScopeVisualizer fixtureName="scopes/php/interior/interior.for" />
297297

298+
##### Shell Script
299+
300+
<ScopeVisualizer fixtureName="scopes/shellscript/interior/interior.for" />
301+
298302
### Interior: Foreach
299303

300304
<i>The body of a for-each loop</i>
@@ -357,6 +361,10 @@ The following are internal scopes. They are not intended for user interaction or
357361

358362
<ScopeVisualizer fixtureName="scopes/scala/interior/interior.foreach" />
359363

364+
##### Shell Script
365+
366+
<ScopeVisualizer fixtureName="scopes/shellscript/interior/interior.foreach" />
367+
360368
##### Talon
361369

362370
<ScopeVisualizer fixtureName="scopes/talon/interior.foreach" />
@@ -429,6 +437,12 @@ The following are internal scopes. They are not intended for user interaction or
429437

430438
<ScopeVisualizer fixtureName="scopes/scss/interior.function" />
431439

440+
##### Shell Script
441+
442+
<ScopeVisualizer fixtureName="scopes/shellscript/interior/interior.function" />
443+
444+
<ScopeVisualizer fixtureName="scopes/shellscript/interior/interior.function2" />
445+
432446
### Interior: If
433447

434448
<i>The body of an if/elif/else branch</i>
@@ -497,6 +511,10 @@ The following are internal scopes. They are not intended for user interaction or
497511

498512
<ScopeVisualizer fixtureName="scopes/scss/interior.if" />
499513

514+
##### Shell Script
515+
516+
<ScopeVisualizer fixtureName="scopes/shellscript/interior/interior.if" />
517+
500518
##### Talon
501519

502520
<ScopeVisualizer fixtureName="scopes/talon/interior.if" />
@@ -757,6 +775,10 @@ The following are internal scopes. They are not intended for user interaction or
757775

758776
<ScopeVisualizer fixtureName="scopes/scala/interior/interior.switch" />
759777

778+
##### Shell Script
779+
780+
<ScopeVisualizer fixtureName="scopes/shellscript/interior/interior.switch" />
781+
760782
### Interior: Switch case
761783

762784
<i>The body of a case/default branch in a switch statement</i>
@@ -837,6 +859,10 @@ The following are internal scopes. They are not intended for user interaction or
837859

838860
<ScopeVisualizer fixtureName="scopes/scala/interior/interior.switchCase2" />
839861

862+
##### Shell Script
863+
864+
<ScopeVisualizer fixtureName="scopes/shellscript/interior/interior.switchCase" />
865+
840866
### Interior: Try
841867

842868
<i>The body of a try/catch/finally branch</i>
@@ -943,4 +969,10 @@ The following are internal scopes. They are not intended for user interaction or
943969

944970
<ScopeVisualizer fixtureName="scopes/scala/interior/interior.while" />
945971

972+
##### Shell Script
973+
974+
<ScopeVisualizer fixtureName="scopes/shellscript/interior/interior.while" />
975+
976+
<ScopeVisualizer fixtureName="scopes/shellscript/interior/interior.while2" />
977+
946978
</ScopeVisualizerProvider>

‎packages/app-web-docs/src/docs/contributing/private-scopes/string.mdx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ The following are internal scopes. They are not intended for user interaction or
8989

9090
<ScopeVisualizer fixtureName="scopes/scala/string.multiLine" />
9191

92+
##### Shell Script
93+
94+
<ScopeVisualizer fixtureName="scopes/shellscript/string.multiLine" />
95+
9296
##### YAML
9397

9498
<ScopeVisualizer fixtureName="scopes/yaml/string.multiLine" />
@@ -177,6 +181,10 @@ The following are internal scopes. They are not intended for user interaction or
177181

178182
<ScopeVisualizer fixtureName="scopes/scm/string.singleLine" />
179183

184+
##### Shell Script
185+
186+
<ScopeVisualizer fixtureName="scopes/shellscript/string.singleLine" />
187+
180188
##### Talon list
181189

182190
<ScopeVisualizer fixtureName="scopes/talon-list/string.singleLine" />

0 commit comments

Comments
 (0)