You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/PULL_REQUEST_TEMPLATE/new_programming_language.md
+1
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ Adds support for the `<language>` programming language
11
11
-[ ]`"chuck arg"` with multiple arguments in list
12
12
-[ ]`"chuck item"` with single argument in list
13
13
-[ ]`"chuck item"` with multiple arguments in list
14
+
-[ ] Added `@textFragment` captures. Usually you want to put these on comment and string nodes. This enables `"take round"` to work within comments and strings.
14
15
-[ ] Added a test for `"change round"` inside a string, eg `"hello (there)"`
15
16
-[ ] Supported` "type"` both for type annotations (eg `foo: string`) and declarations (eg `interface Foo {}`) (and added tests for this behaviour 😊)
16
17
-[ ] Supported` "item"` both for map pairs and list entries (with tests of course)
Copy file name to clipboardExpand all lines: docs/contributing/adding-a-new-language.md
+5-10
Original file line number
Diff line number
Diff line change
@@ -16,20 +16,15 @@ First a few notes / tips:
16
16
- We suggest opening a draft PR as soon as possible to get early feedback. Please use the new language PR template either by adding `?template=new_programming_language` to the end of the URL you used to open the PR, or just by copying and pasting from the [template](https://github.com/cursorless-dev/cursorless/blob/main/.github/PULL_REQUEST_TEMPLATE/new_programming_language.md?plain=1) to your PR body, if that's easier.
17
17
- We suggest adding tests as early as possible, after each language feature you add. Recording tests is quick and painless using the test case recorder described below. We promise 😇
18
18
19
-
Minimum changes that each language needs:
20
-
21
-
- new file in `packages/cursorless-engine/src/languages/yourCoolNewLanguage.ts`. Take a look at [existing languages](../../packages/cursorless-engine/src/languages) as a base. At its core you're implementing your language's version of the `nodeMatchers` const, mapping scope types found in [`SimpleScopeTypeType`](../api/modules/common_src_types_command_partialtargetdescriptor_types/#simplescopetypetype) with matching expressions that align with the parse tree output.
22
-
- new entry in [`getNodeMatcher.ts:languageMatchers`](../../packages/cursorless-engine/src/languages/getNodeMatcher.ts), importing your new file above
23
-
- new entry in [`constants.ts`](../../packages/cursorless-engine/src/languages/constants.ts)
24
-
- new text fragment extractor (default is likely fine) in [`getTextFragmentExtractor.ts:textFragmentExtractors`](../../packages/cursorless-engine/src/languages/getTextFragmentExtractor.ts)
19
+
To add a new language, you just need to add a `.scm` file to the [`queries` directory](../../queries). The `.scm` query format is documented [here](https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax).
25
20
26
21
The parse trees exposed by tree-sitter are often pretty close to what we're
27
22
looking for, but we often need to look for specific patterns within the parse
28
-
tree to get the scopes that the user expects. Fortunately, we have a
29
-
domain-specific language that makes these definitions fairly compact.
23
+
tree to get the scopes that the user expects. Fortunately, the tree-sitter query language makes these definitions fairly compact.
30
24
31
-
- Check out the [docs](parse-tree-patterns.md) for the syntax tree pattern
32
-
matcher
25
+
- Check out the [docs](https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax) for the query language.
26
+
- Have a look at our custom query predicate operators in [`queryPredicateOperators.ts`](../../packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts)
27
+
- Look at the existing language definitions in the [`queries` directory](../../queries) for examples.
33
28
- If you look in the debug console, you'll see debug output every time you move
34
29
your cursor, which might be helpful.
35
30
- You will likely want to look at `node-types.json` for your language, (eg [java](https://github.com/tree-sitter/tree-sitter-java/blob/master/src/node-types.json)). This file is generated from `grammar.js`, which might also be helpful to look at (eg [java](https://github.com/tree-sitter/tree-sitter-java/blob/master/grammar.js)).
Copy file name to clipboardExpand all lines: docs/user/README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,7 @@ Note that if the mark is `"this"`, and you have multiple cursors, the modifiers
143
143
144
144
##### Syntactic scopes
145
145
146
-
For programming languages where Cursorless has rich parse tree support, we support modifiers that expand to the nearest containing function, class, etc. See [the source code](../../packages/cursorless-engine/src/languages/constants.ts) for a list of supported languages. Below is a list of supported scope types, keeping in mind that this table can sometimes lag behind the actual list. Your cheatsheet (say `"cursorless cheatsheet"` with VSCode focused) will have the most up-to-date list.
146
+
For programming languages where Cursorless has rich parse tree support, we support modifiers that expand to the nearest containing function, class, etc. See [the source code](../../queries) for a list of supported languages. Some languages are still supported using our legacy implementation; those will be listed in [here](../../packages/cursorless-engine/src/languages/LegacyLanguageId.ts). Below is a list of supported scope types, keeping in mind that this table can sometimes lag behind the actual list. Your cheatsheet (say `"cursorless cheatsheet"` with VSCode focused) will have the most up-to-date list.
0 commit comments