From 1863ed992745ff7e6ee90d3efa38c9a842a018ea Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Wed, 11 Aug 2021 10:29:51 +0800 Subject: [PATCH] Add ledger tree-sitter Might need to update later since the current one highlight does not work very well yet. --- .gitmodules | 4 +++ helix-syntax/languages/tree-sitter-ledger | 1 + languages.toml | 9 ++++++ runtime/queries/ledger/highlights.scm | 38 +++++++++++++++++++++++ runtime/queries/ledger/injections.scm | 1 + 5 files changed, 53 insertions(+) create mode 160000 helix-syntax/languages/tree-sitter-ledger create mode 100644 runtime/queries/ledger/highlights.scm create mode 100644 runtime/queries/ledger/injections.scm diff --git a/.gitmodules b/.gitmodules index 87acea60741c..a1c0589ecd4e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -94,3 +94,7 @@ path = helix-syntax/languages/tree-sitter-latex url = https://github.com/latex-lsp/tree-sitter-latex shallow = true +[submodule "helix-syntax/languages/tree-sitter-ledger"] + path = helix-syntax/languages/tree-sitter-ledger + url = https://github.com/cbarrete/tree-sitter-ledger + shallow = true diff --git a/helix-syntax/languages/tree-sitter-ledger b/helix-syntax/languages/tree-sitter-ledger new file mode 160000 index 000000000000..72319504776f --- /dev/null +++ b/helix-syntax/languages/tree-sitter-ledger @@ -0,0 +1 @@ +Subproject commit 72319504776f14193472a6ad14abec0af0225cbe diff --git a/languages.toml b/languages.toml index 15d78a1af341..30ef3582bfcf 100644 --- a/languages.toml +++ b/languages.toml @@ -205,6 +205,15 @@ file-types = ["java"] roots = [] indent = { tab-width = 4, unit = " " } +[[language]] +name = "ledger" +scope = "source.ledger" +injection-regex = "ledger" +file-types = ["ldg", "ledger", "journal"] +roots = [] +comment-token = ";" +indent = { tab-width = 4, unit = " " } + # [[language]] # name = "haskell" # scope = "source.haskell" diff --git a/runtime/queries/ledger/highlights.scm b/runtime/queries/ledger/highlights.scm new file mode 100644 index 000000000000..86c609c2a9a2 --- /dev/null +++ b/runtime/queries/ledger/highlights.scm @@ -0,0 +1,38 @@ +[ + (comment) + (note) +] @comment + +[ + (date) + (interval) + (quantity) +] @number + +((account) @field) +((commodity) @text.literal) + +"include" @include + +[ + "account" + "alias" + "assert" + "check" + "commodity" + "def" + "default" + "end" + "eval" + "format" + "nomarket" + "note" + "payee" + "check" + "A" + "Y" + "N" + "D" + "C" + "P" +] @keyword diff --git a/runtime/queries/ledger/injections.scm b/runtime/queries/ledger/injections.scm new file mode 100644 index 000000000000..4bb7d675dfac --- /dev/null +++ b/runtime/queries/ledger/injections.scm @@ -0,0 +1 @@ +(comment) @comment