From e2e8e52ec4eb4c053b4148c063a775bed30c7d94 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 5 Feb 2024 11:07:26 -0700 Subject: [PATCH] Beancount syntax highlighting (#7389) Release Notes: - Added syntax highlighting for [Beancount](https://beancount.github.io) --- Cargo.lock | 10 +++++++++ Cargo.toml | 1 + crates/zed/Cargo.toml | 1 + crates/zed/src/languages.rs | 1 + .../zed/src/languages/beancount/config.toml | 3 +++ .../src/languages/beancount/highlights.scm | 21 +++++++++++++++++++ 6 files changed, 37 insertions(+) create mode 100644 crates/zed/src/languages/beancount/config.toml create mode 100644 crates/zed/src/languages/beancount/highlights.scm diff --git a/Cargo.lock b/Cargo.lock index ad58e4442533570bfc90c1fbefb5c70a6b1f1422..40d594ff42b109a7def4f89fedb2f16ccda05d4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8729,6 +8729,15 @@ dependencies = [ "tree-sitter", ] +[[package]] +name = "tree-sitter-beancount" +version = "2.2.0" +source = "git+https://github.com/polarmutex/tree-sitter-beancount?rev=da1bf8c6eb0ae7a97588affde7227630bcd678b6#da1bf8c6eb0ae7a97588affde7227630bcd678b6" +dependencies = [ + "cc", + "tree-sitter", +] + [[package]] name = "tree-sitter-c" version = "0.20.6" @@ -10369,6 +10378,7 @@ dependencies = [ "toml", "tree-sitter", "tree-sitter-bash", + "tree-sitter-beancount", "tree-sitter-c", "tree-sitter-c-sharp", "tree-sitter-cpp", diff --git a/Cargo.toml b/Cargo.toml index 5a276ef8b3b54b22e7ddeefb1a664f765b991400..edfc968ffb2c2c27e144965b61f7eb54135d5dfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -141,6 +141,7 @@ time = { version = "0.3", features = ["serde", "serde-well-known"] } toml = "0.5" tree-sitter = { version = "0.20", features = ["wasm"] } tree-sitter-bash = { git = "https://github.com/tree-sitter/tree-sitter-bash", rev = "7331995b19b8f8aba2d5e26deb51d2195c18bc94" } +tree-sitter-beancount = { git = "https://github.com/polarmutex/tree-sitter-beancount", rev = "da1bf8c6eb0ae7a97588affde7227630bcd678b6" } tree-sitter-c = "0.20.1" tree-sitter-c-sharp = { git = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "dd5e59721a5f8dae34604060833902b882023aaf" } tree-sitter-cpp = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "f44509141e7e483323d2ec178f2d2e6c0fc041c1" } diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 61df53a9fb27c0fb4f48119eb2fe7ea0e2a7c45b..f3ba0825c7a04a49bfe0208155502413e4ce14b8 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -108,6 +108,7 @@ thiserror.workspace = true tiny_http = "0.8" toml.workspace = true tree-sitter-bash.workspace = true +tree-sitter-beancount.workspace = true tree-sitter-c-sharp.workspace = true tree-sitter-c.workspace = true tree-sitter-cpp.workspace = true diff --git a/crates/zed/src/languages.rs b/crates/zed/src/languages.rs index 15bd180a2ebeac074d9c0bf00ea134b8b5c92fc3..248ff3c7fde6b6e047260bdd0b1709fc2354d8c1 100644 --- a/crates/zed/src/languages.rs +++ b/crates/zed/src/languages.rs @@ -67,6 +67,7 @@ pub fn init( }; language("bash", tree_sitter_bash::language(), vec![]); + language("beancount", tree_sitter_beancount::language(), vec![]); language( "c", tree_sitter_c::language(), diff --git a/crates/zed/src/languages/beancount/config.toml b/crates/zed/src/languages/beancount/config.toml new file mode 100644 index 0000000000000000000000000000000000000000..722b8a39b74bb54eb71148a7d1e93d3134448dd2 --- /dev/null +++ b/crates/zed/src/languages/beancount/config.toml @@ -0,0 +1,3 @@ +name = "Beancount" +path_suffixes = ["beancount"] +brackets = [{ start = "\"", end = "\"", close = false, newline = false }] diff --git a/crates/zed/src/languages/beancount/highlights.scm b/crates/zed/src/languages/beancount/highlights.scm new file mode 100644 index 0000000000000000000000000000000000000000..87a383ddbf306b14556b49f8059a64131496c926 --- /dev/null +++ b/crates/zed/src/languages/beancount/highlights.scm @@ -0,0 +1,21 @@ +(comment) @comment +(headline) @comment +[ + (payee) + (narration) + (string) +] @string + +(number) @number +(date) @function +(currency) @constant +(account) @identifier + +[ + (option) + (include) + (open) + (balance) + (pad) + (close) +] @keyword