Skip to content

Commit

Permalink
feat: add Prisma Schema language support
Browse files Browse the repository at this point in the history
  • Loading branch information
ewen-lbh committed May 30, 2024
1 parent 5d8a14d commit 9c57b21
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ fn main() {
src_dir: "vendored_parsers/tree-sitter-solidity-src",
extra_files: vec![],
},
TreeSitterParser {
name: "tree-sitter-prisma",
src_dir: "vendored_parsers/tree-sitter-prisma-src",
extra_files: vec![],
},
];

// Only rerun if relevant files in the vendored_parsers/ directory change.
Expand Down
3 changes: 3 additions & 0 deletions src/parse/guess_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub(crate) enum Language {
Pascal,
Perl,
Php,
Prisma,
Python,
Qml,
R,
Expand Down Expand Up @@ -154,6 +155,7 @@ pub(crate) fn language_name(language: Language) -> &'static str {
Pascal => "Pascal",
Perl => "Perl",
Php => "PHP",
Prisma => "Prisma",
Python => "Python",
Qml => "QML",
R => "R",
Expand Down Expand Up @@ -339,6 +341,7 @@ pub(crate) fn language_globs(language: Language) -> Vec<glob::Pattern> {
Php => &[
"*.php", "*.phtml", "*.php3", "*.php4", "*.php5", "*.php7", "*.phps",
],
Prisma => &["*.prisma"],
Python => &["*.py", "*.py3", "*.pyi", "*.bzl", "TARGETS", "BUCK", "DEPS"],
Qml => &["*.qml"],
R => &["*.R", "*.r", "*.rd", "*.rsx", ".Rprofile", "expr-dist"],
Expand Down
15 changes: 15 additions & 0 deletions src/parse/tree_sitter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ extern "C" {
fn tree_sitter_dart() -> ts::Language;
fn tree_sitter_devicetree() -> ts::Language;
fn tree_sitter_elisp() -> ts::Language;
fn tree_sitter_prisma() -> ts::Language;
fn tree_sitter_elixir() -> ts::Language;
fn tree_sitter_elm() -> ts::Language;
fn tree_sitter_elvish() -> ts::Language;
Expand Down Expand Up @@ -881,6 +882,20 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig {
sub_languages: vec![],
}
}
Prisma => {
let language = unsafe { tree_sitter_prisma() };
TreeSitterConfig {
language,
atom_nodes: vec!["string"].into_iter().collect(),
delimiter_tokens: vec![("{", "}"), ("(", ")"), ("[", "]")],
highlight_query: ts::Query::new(
language,
include_str!("../../vendored_parsers/highlights/prisma.scm"),
)
.unwrap(),
sub_languages: vec![],
}
}
Python => {
let language = unsafe { tree_sitter_python() };
TreeSitterConfig {
Expand Down
1 change: 1 addition & 0 deletions vendored_parsers/highlights/prisma.scm
26 changes: 13 additions & 13 deletions vendored_parsers/tree-sitter-c/test/corpus/crlf.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
============================================
Line comments with escaped CRLF line endings
============================================
// hello \
this is still a comment
this_is_not a_comment;
---
(translation_unit
(comment)
(declaration (type_identifier) (identifier)))
============================================
Line comments with escaped CRLF line endings
============================================

// hello \
this is still a comment
this_is_not a_comment;

---

(translation_unit
(comment)
(declaration (type_identifier) (identifier)))
1 change: 1 addition & 0 deletions vendored_parsers/tree-sitter-prisma-src

0 comments on commit 9c57b21

Please sign in to comment.