@@ -2,33 +2,38 @@ import init, { setupParser, initializeTreeSitter, findNodes, fixErrors } from 'a
22import type { InjectionKey , Ref } from 'vue'
33import { shallowRef , watchEffect , provide } from 'vue'
44
5- export type SupportedLang = keyof typeof parserPaths
5+ export type SupportedLang = keyof typeof langConfig
66
7- const parserPaths = {
8- javascript : 'tree-sitter-javascript.wasm ' ,
9- typescript : 'tree-sitter-typescript.wasm ' ,
10- tsx : ' tree-sitter-tsx.wasm',
7+ const langConfig = {
8+ javascript : '0.23.1 ' ,
9+ typescript : '0.23.2 ' ,
10+ tsx :
( ) => 'https://unpkg.com/[email protected] / tree-sitter-tsx.wasm', 1111 // not so well supported lang...
12- bash : 'tree-sitter-bash.wasm ' ,
13- c : 'tree-sitter-c.wasm ' ,
14- csharp : 'tree-sitter-c_sharp.wasm' ,
15- css : 'tree-sitter-css.wasm ' ,
16- cpp : 'tree-sitter-cpp.wasm ' ,
17- elixir : 'tree-sitter-elixir.wasm' ,
18- go : 'tree-sitter-go.wasm ' ,
19- html : 'tree-sitter-html.wasm ' ,
20- java : 'tree-sitter-java.wasm ' ,
21- json : 'tree-sitter-json.wasm ' ,
22- kotlin : 'tree-sitter-kotlin.wasm' ,
23- php : 'https://unpkg.com/tree-sitter-php@ 0.23.11/tree-sitter-php.wasm ' ,
24- python : 'tree-sitter-python.wasm ' ,
25- ruby : 'tree-sitter-ruby.wasm ' ,
26- rust : 'tree-sitter-rust.wasm ' ,
27- scala : 'tree-sitter-scala.wasm ' ,
28- swift : 'tree-sitter-swift.wasm' ,
29- yaml : ' tree-sitter-yaml.wasm',
12+ bash : '0.23.2 ' ,
13+ c : '0.23.2 ' ,
14+ csharp : ( ) => 'tree-sitter-c_sharp.wasm' ,
15+ css : '0.23.2 ' ,
16+ cpp : '0.23.2 ' ,
17+ elixir : ( ) => 'tree-sitter-elixir.wasm' ,
18+ go : '0.23.2 ' ,
19+ html : '0.23.2 ' ,
20+ java : '0.23.3 ' ,
21+ json : '0.24.2 ' ,
22+ kotlin : ( ) => 'tree-sitter-kotlin.wasm' ,
23+ php : '0.23.11' ,
24+ python : '0.23.3 ' ,
25+ ruby : '0.23.1 ' ,
26+ rust : '0.23.2 ' ,
27+ scala : '0.23.3 ' ,
28+ swift : ( ) => 'tree-sitter-swift.wasm' ,
29+ yaml :
( ) => 'https://unpkg.com/@tree-sitter-grammars/[email protected] / tree-sitter-yaml.wasm', 3030}
3131
32+ const parserPaths = Object . fromEntries ( Object . entries ( langConfig ) . map ( ( [ lang , config ] ) => [
33+ lang , typeof config === 'function' ? config ( ) : `https://unpkg.com/tree-sitter-${ lang } @${ config } /${ lang } .wasm`
34+ ] ) ) as Record < SupportedLang , string >
35+
36+
3237// monaco does not realize bash is shell but shell is not bash.
3338// use this mapping to highlight bash
3439const monacoLangMapping : Record < string , string > = {
0 commit comments