From 4477cca9698c9c012866c69903d8a2038810f8a6 Mon Sep 17 00:00:00 2001 From: Duane Bester Date: Wed, 4 Jun 2025 22:54:52 -0500 Subject: [PATCH] highlighter: Adding tree-sitter-sequel for SQL support. (#917) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 📦 Adding dependency: [tree-sitter-sequel](https://github.com/derekstride/tree-sitter-sql) ### Previews Screenshot 2025-06-04 at 9 27 08 PM Screenshot 2025-06-04 at 9 34 02 PM --- Cargo.lock | 11 +++++++++++ crates/story/examples/code-editor.rs | 3 ++- crates/story/examples/fixtures/test.sql | 5 +++++ crates/ui/Cargo.toml | 1 + crates/ui/src/highlighter/languages.rs | 10 ++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 crates/story/examples/fixtures/test.sql diff --git a/Cargo.lock b/Cargo.lock index ccaa4b08..4c2a2879 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2898,6 +2898,7 @@ dependencies = [ "tree-sitter-ruby", "tree-sitter-rust", "tree-sitter-scala", + "tree-sitter-sequel", "tree-sitter-swift", "tree-sitter-toml-ng", "tree-sitter-typescript", @@ -7716,6 +7717,16 @@ dependencies = [ "tree-sitter-language", ] +[[package]] +name = "tree-sitter-sequel" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f2550ddbfd7f52da6d7fd4bb145e20dc67f3a0cdfdae068034a2a16101e668b" +dependencies = [ + "cc", + "tree-sitter-language", +] + [[package]] name = "tree-sitter-swift" version = "0.7.0" diff --git a/crates/story/examples/code-editor.rs b/crates/story/examples/code-editor.rs index e5fc134f..6bb82c37 100644 --- a/crates/story/examples/code-editor.rs +++ b/crates/story/examples/code-editor.rs @@ -18,7 +18,7 @@ pub struct Example { _subscribes: Vec, } -const LANGUAGES: [(Language, &'static str); 7] = [ +const LANGUAGES: [(Language, &'static str); 8] = [ (Language::Rust, include_str!("./fixtures/test.rs")), (Language::JavaScript, include_str!("./fixtures/test.js")), (Language::Go, include_str!("./fixtures/test.go")), @@ -26,6 +26,7 @@ const LANGUAGES: [(Language, &'static str); 7] = [ (Language::Ruby, include_str!("./fixtures/test.rb")), (Language::Zig, include_str!("./fixtures/test.zig")), (Language::C, include_str!("./fixtures/test.c")), + (Language::Sql, include_str!("./fixtures/test.sql")), ]; impl Example { diff --git a/crates/story/examples/fixtures/test.sql b/crates/story/examples/fixtures/test.sql new file mode 100644 index 00000000..28f0e248 --- /dev/null +++ b/crates/story/examples/fixtures/test.sql @@ -0,0 +1,5 @@ +SELECT * +FROM users +WHERE email ilike '%test%' + AND deleted_at IS NOT NULL +LIMIT 1; diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index d55d3266..1eb08527 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -79,6 +79,7 @@ tree-sitter-ruby = "0.23.1" tree-sitter-rust = "0.24.0" tree-sitter-scala = "0.23.4" tree-sitter-swift = "0.7.0" +tree-sitter-sequel = "0.3.8" tree-sitter-toml-ng = "0.7.0" tree-sitter-typescript = "0.23.2" tree-sitter-yaml = "0.7.1" diff --git a/crates/ui/src/highlighter/languages.rs b/crates/ui/src/highlighter/languages.rs index d39be15f..a7a64ef6 100644 --- a/crates/ui/src/highlighter/languages.rs +++ b/crates/ui/src/highlighter/languages.rs @@ -22,6 +22,7 @@ pub enum Language { Css, Swift, Scala, + Sql, CSharp, GraphQL, Proto, @@ -90,6 +91,7 @@ impl Language { Self::Css => "css", Self::Swift => "swift", Self::Scala => "scala", + Self::Sql => "sql", Self::CSharp => "csharp", Self::GraphQL => "graphql", Self::Proto => "proto", @@ -125,6 +127,7 @@ impl Language { "css" | "scss" => Some(Self::Css), "swift" => Some(Self::Swift), "scala" => Some(Self::Scala), + "sql" => Some(Self::Sql), "csharp" | "cs" => Some(Self::CSharp), "graphql" => Some(Self::GraphQL), "proto" | "protobuf" => Some(Self::Proto), @@ -270,6 +273,12 @@ impl Language { "", tree_sitter_scala::LOCALS_QUERY, ), + Self::Sql => ( + tree_sitter_sequel::LANGUAGE, + tree_sitter_sequel::HIGHLIGHTS_QUERY, + "", + "", + ), Self::CSharp => (tree_sitter_c_sharp::LANGUAGE, "", "", ""), Self::GraphQL => (tree_sitter_graphql::LANGUAGE, "", "", ""), Self::Proto => (tree_sitter_proto::LANGUAGE, "", "", ""), @@ -338,6 +347,7 @@ mod tests { assert_eq!(Language::Go.name(), "go"); assert_eq!(Language::C.name(), "c"); assert_eq!(Language::Cpp.name(), "cpp"); + assert_eq!(Language::Sql.name(), "sql"); assert_eq!(Language::JavaScript.name(), "javascript"); assert_eq!(Language::Zig.name(), "zig"); assert_eq!(Language::CSharp.name(), "csharp");