Skip to content

Commit

Permalink
Merge branch 'dgmcdona/tree-sitter-powershell'
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Dec 21, 2024
2 parents 82d31cc + 59458aa commit 551d793
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ javascript
markdown
nix
php
powershell
python
ruby
rust
Expand Down
17 changes: 17 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,21 @@ fn main() {
.warnings(false)
.file(typescript_dir.join("scanner.c"))
.compile("tree_sitter_typescript_scanner");

// powershell
let powershell_dir: PathBuf = ["vendor", "tree-sitter-powershell", "src"].iter().collect();

println!("cargo:rerun-if-changed=vendor/tree-sitter-powershell/src/parser.c");
cc::Build::new()
.include(&powershell_dir)
.warnings(false)
.file(&powershell_dir.join("parser.c"))
.compile("tree-sitter-powershell");

println!("cargo:rerun-if-changed=vendor/tree-sitter-powershell/src/scanner.c");
cc::Build::new()
.include(&powershell_dir)
.warnings(false)
.file(&powershell_dir.join("scanner.c"))
.compile("tree_sitter_powershell_scanner");
}
17 changes: 17 additions & 0 deletions flake.lock

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

6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
url = "github:theHamsta/tree-sitter-cuda/v0.20.3";
flake = false;
};

tree-sitter-powershell = {
url = "github:airbus-cert/tree-sitter-powershell";
flake = false;
};
};

outputs = inputs:
Expand Down Expand Up @@ -123,6 +128,7 @@
ln -s ${inputs.tree-sitter-typescript} vendor/tree-sitter-typescript
ln -s ${inputs.tree-sitter-nix} vendor/tree-sitter-nix
ln -s ${inputs.tree-sitter-cuda} vendor/tree-sitter-cuda
ln -s ${inputs.tree-sitter-powershell} vendor/tree-sitter-powershell
'';
in rec {
# `nix build`
Expand Down
1 change: 1 addition & 0 deletions src/extractor_chooser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl<'extractor> ExtractorChooser<'extractor> {
types_builder.add_defaults();
types_builder.add_def("cuda:*.cu,*.cuh,*.hpp")?;
types_builder.add_def("cuda:include:cpp")?;
types_builder.add_def("powershell:*.ps1")?;

let mut names_to_extractors = HashMap::with_capacity(extractors.len());

Expand Down
4 changes: 4 additions & 0 deletions src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub enum Language {
Markdown,
Nix,
Php,
PowerShell,
Python,
Ruby,
Rust,
Expand Down Expand Up @@ -45,6 +46,7 @@ impl Language {
Language::Markdown => tree_sitter_markdown(),
Language::Nix => tree_sitter_nix(),
Language::Php => tree_sitter_php(),
Language::PowerShell => tree_sitter_powershell(),
Language::Python => tree_sitter_python(),
Language::Ruby => tree_sitter_ruby(),
Language::Rust => tree_sitter_rust(),
Expand Down Expand Up @@ -77,6 +79,7 @@ impl Language {
Language::Rust => "rust",
Language::Sass => "sass",
Language::TypeScript => "ts",
Language::PowerShell => "powershell",
}
}
}
Expand Down Expand Up @@ -112,6 +115,7 @@ extern "C" {
fn tree_sitter_markdown() -> tree_sitter::Language;
fn tree_sitter_nix() -> tree_sitter::Language;
fn tree_sitter_php() -> tree_sitter::Language;
fn tree_sitter_powershell() -> tree_sitter::Language;
fn tree_sitter_python() -> tree_sitter::Language;
fn tree_sitter_ruby() -> tree_sitter::Language;
fn tree_sitter_rust() -> tree_sitter::Language;
Expand Down
1 change: 1 addition & 0 deletions tests/cmd/languages.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ javascript
markdown
nix
php
powershell
python
ruby
rust
Expand Down

0 comments on commit 551d793

Please sign in to comment.