aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle L. Davis2022-08-08 22:59:55 +0000
committerGitHub2022-08-08 22:59:55 +0000
commit4ce5a94552d887b9b14000dfdd1abe76a6d5f315 (patch)
tree7862e28e5dad432705111496889355ead9b13dac
parentd9321134f6c0f2a009540812bacfaa6a4b621751 (diff)
Add language: beancount (#3297)
Co-authored-by: erasin <erasinoo@gmail.com> Co-authored-by: Michael Davis <mcarsondavis@gmail.com> Co-authored-by: Erasin <erasinoo@gmail.com>
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml13
-rw-r--r--runtime/queries/beancount/folds.scm4
-rw-r--r--runtime/queries/beancount/highlights.scm49
4 files changed, 67 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index a79f79f0..432efb78 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -1,6 +1,7 @@
| Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default LSP |
| --- | --- | --- | --- | --- |
| bash | ✓ | | | `bash-language-server` |
+| beancount | ✓ | | | |
| c | ✓ | ✓ | ✓ | `clangd` |
| c-sharp | ✓ | | | `OmniSharp` |
| cairo | ✓ | | | |
diff --git a/languages.toml b/languages.toml
index 287d4534..c1f197aa 100644
--- a/languages.toml
+++ b/languages.toml
@@ -600,6 +600,19 @@ name = "ledger"
source = { git = "https://github.com/cbarrete/tree-sitter-ledger", rev = "1f864fb2bf6a87fe1b48545cc6adc6d23090adf7" }
[[language]]
+name = "beancount"
+scope = "source.beancount"
+injection-regex = "beancount"
+file-types = ["beancount", "bean"]
+roots = []
+comment-token = ";"
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "beancount"
+source = { git = "https://github.com/polarmutex/tree-sitter-beancount", rev = "4cbd1f09cd07c1f1fabf867c2cf354f9da53cc4c" }
+
+[[language]]
name = "ocaml"
scope = "source.ocaml"
injection-regex = "ocaml"
diff --git a/runtime/queries/beancount/folds.scm b/runtime/queries/beancount/folds.scm
new file mode 100644
index 00000000..9f1b6cbe
--- /dev/null
+++ b/runtime/queries/beancount/folds.scm
@@ -0,0 +1,4 @@
+[
+ (transaction)
+ (section)
+] @fold
diff --git a/runtime/queries/beancount/highlights.scm b/runtime/queries/beancount/highlights.scm
new file mode 100644
index 00000000..440a5782
--- /dev/null
+++ b/runtime/queries/beancount/highlights.scm
@@ -0,0 +1,49 @@
+(date) @variable.builtin
+(txn) @variable.builtin
+
+(account) @type
+
+[
+ (amount)
+ (incomplete_amount)
+ (amount_tolerance)
+ (number)
+] @constant.numeric
+
+
+[(key_value) (key)] @variable.other.member
+(string) @string
+
+[
+ (currency)
+ (tag)
+ (link)
+] @constant
+
+(comment) @comment
+
+[
+ (minus)
+ (plus)
+] @operator
+
+[
+ (balance) (open) (close) (commodity) (pad)
+ (event) (price) (note) (document) (query)
+ (custom) (pushtag) (poptag) (pushmeta)
+ (popmeta) (option) (include) (plugin)
+] @keyword
+
+
+((headline item: (item) @markup.heading.6) @markup.heading.marker
+ (#match? @markup.heading.marker "^\\*\\*\\*\\*\\*\\*"))
+((headline item: (item) @markup.heading.5) @markup.heading.marker
+ (#match? @markup.heading.marker "^\\*\\*\\*\\*\\*"))
+((headline item: (item) @markup.heading.4) @markup.heading.marker
+ (#match? @markup.heading.marker "^\\*\\*\\*\\*"))
+((headline item: (item) @markup.heading.3) @markup.heading.marker
+ (#match? @markup.heading.marker "^\\*\\*\\*"))
+((headline item: (item) @markup.heading.2) @markup.heading.marker
+ (#match? @markup.heading.marker "^\\*\\*"))
+((headline item: (item) @markup.heading.1) @markup.heading.marker
+ (#match? @markup.heading.marker "^\\*"))