Skip to content

Commit 2e393a3

Browse files
committed
document mapping
1 parent 672141b commit 2e393a3

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

docs/src/content/docs/reference/scripts/ast-grep.mdx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ This version of `ast-grep` [supports the following built-in languages](https://a
131131
132132
- Html
133133
- JavaScript
134+
- TypeScript
134135
- Tsx
135136
- Css
136-
- TypeScript
137137
138138
The following languages require installing an additional package:
139139
@@ -155,6 +155,21 @@ If your language is not supported, go to [ast-grep langs](https://github.com/ast
155155
156156
:::
157157
158+
### Overriding the language selection
159+
160+
GenAIScript has default mappings from well-known file extensions to languages.
161+
However, you can override this by passing the `lang` option to the `search` method.
162+
163+
```ts "{ lang: "ts" }"
164+
const { matches } = await sg.search("src/fib.ts", {...}, { lang: "ts" })
165+
```
166+
167+
or if you want to search multiple languages, by providing a `extension` to `lang` mapping.
168+
169+
```ts 'lang: { "ttts": "ts", "jjjs":"js" }'
170+
const { matches } = await sg.search("src/*", {...}, { lang: { "ttts": "ts", "jjjs":"js" } })
171+
```
172+
158173
## Learning ast-grep
159174
160175
There is a learning curve to grasp the query language of `ast-grep`.

0 commit comments

Comments
 (0)