Skip to content

Commit

Permalink
feat: support yaml in playground
Browse files Browse the repository at this point in the history
  • Loading branch information
HerringtonDarkholme committed Sep 7, 2024
1 parent 2124b52 commit 87ae125
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ console_error_panic_hook = { version = "0.1.7", optional = true }

once_cell = "1.19.0"
wee_alloc = { version = "0.4.5" }
ast-grep-core = { version = "0.26.3" }
ast-grep-config = { version = "0.26.3" }
ast-grep-language = { version = "0.26.3", default-features = false }
ast-grep-core = { version = "0.27.0" }
ast-grep-config = { version = "0.27.0" }
ast-grep-language = { version = "0.27.0", default-features = false }
web-tree-sitter-sg = "0.22.2"
tree-sitter = { version = "0.22.2", package = "tree-sitter-facade-sg" }
serde-wasm-bindgen = "0.6"
Expand Down
3 changes: 3 additions & 0 deletions src/wasm_lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub enum WasmLang {
Rust,
Scala,
Swift,
Yaml,
}

use WasmLang::*;
Expand Down Expand Up @@ -76,6 +77,7 @@ impl FromStr for WasmLang {
"rust" => Rust,
"scala" => Scala,
"swift" => Swift,
"yaml" => Yaml,
_ => return Err(NotSupport(s.to_string())),
})
}
Expand Down Expand Up @@ -154,6 +156,7 @@ macro_rules! execute_lang_method {
W::Swift => L::Swift.$method($($pname,)*),
W::TypeScript => L::TypeScript.$method($($pname,)*),
W::Tsx => L::Tsx.$method($($pname,)*),
W::Yaml => L::Yaml.$method($($pname,)*),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions website/guide/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ast-grep supports a wide range of programming languages. Here is a list of notab
|Server Side Programming| `Go`, `Java`, `Python`, `C-sharp`|
|Web Development| `JS(X)`, `TS(X)`, `HTML`, `CSS`|
|Mobile App Development| `Dart`, `Kotlin`, `Swift`|
|Configuration | `Json`, `YAML`|
|Scripting, Protocols, etc.| `Lua`, `Thrift`|

Thanks to [tree-sitter](https://tree-sitter.github.io/tree-sitter/), a popular parser generator library, ast-grep manages to support [many languages](/reference/languages) out of the box!
Expand Down
Binary file modified website/public/tree-sitter-yaml.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions website/reference/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The table below lists all languages that are supported by ast-grep.
|Swift | `swift` | `swift`|
|TypeScript | `ts`, `typescript` | `ts`, `cts`, `mts`|
|Tsx | `tsx` | `tsx`|
|Yaml | `yml` | `yml`, `yaml`|

----

Expand Down
2 changes: 2 additions & 0 deletions website/src/components/astGrep/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const parserPaths = {
rust: 'tree-sitter-rust.wasm',
scala: 'tree-sitter-scala.wasm',
swift: 'tree-sitter-swift.wasm',
yaml: 'tree-sitter-yaml.wasm',
}

// monaco does not realize bash is shell but shell is not bash.
Expand Down Expand Up @@ -61,6 +62,7 @@ export const languageDisplayNames: Record<SupportedLang, string> = {
rust: 'Rust',
scala: 'Scala',
swift: 'Swift',
yaml: 'YAML',
}

export async function initializeParser() {
Expand Down

0 comments on commit 87ae125

Please sign in to comment.