Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add language: beancount #3297

Merged
merged 14 commits into from
Aug 8, 2022
Merged

Conversation

AceofSpades5757
Copy link
Contributor

@erasin
Copy link
Contributor

erasin commented Aug 3, 2022

we need highlights for beancount

create runtime/queries/beancount/highlights.scm add

(date) @variable.builtin
(txn) @variable.builtin

(account) @type

[
  (amount)
  (incomplete_amount)
  (amount_tolerance) 
  (number)
] @constant.numeric


(key) @label
(string) @string

[
  (currency)
  (tag)
  (link)
] @constant

(comment) @comment

[
  (minus)
  (plus)
] @keyword.operator

[
  (balance) (open) (close) (commodity) (pad)
  (event) (price) (note) (document) (query)
  (custom) (pushtag) (poptag) (pushmeta)
  (popmeta) (option) (include) (plugin)
] @keyword

and next step

cargo xtask docgen

it will be change book/src/generated/lang-support.md

@AceofSpades5757
Copy link
Contributor Author

Yeah, that issue is being handled here: polarmutex/tree-sitter-beancount#12

I'm still not familiar with tree-sitter or LSP and how they work but I did notice the missing checkbox when generating docs for highlighting.

@AceofSpades5757
Copy link
Contributor Author

@erasin Thanks. I'm merging master and adding that now. Appreciate it.

@AceofSpades5757
Copy link
Contributor Author

I haven't had time to check this against some beancount files, but everything looks good now.

@AceofSpades5757 AceofSpades5757 marked this pull request as ready for review August 4, 2022 05:15
@AceofSpades5757
Copy link
Contributor Author

Looks real good.

image

@erasin
Copy link
Contributor

erasin commented Aug 4, 2022

may be we need add bean add to file-types.

file-types = ["beancount","bean"]

VS beancount support type of bean

I use beancount for myself like this

.
├── 2018.bean
├── ...
├── 2022.bean
├── accounts.bean
├── config.bean
└── main.bean

@AceofSpades5757
Copy link
Contributor Author

@erasin But is that supported anywhere else? I'd rather not add built-in support to something just because Microsoft wants to get cute.

@AceofSpades5757
Copy link
Contributor Author

It looks like either a typo or an old version of beancount

@the-mikedavis
Copy link
Member

Sublime allows .bean as well: https://github.com/norseghost/sublime-beancount/blob/761873a101805ad641bc0339f9abae0fa4d51848/beancount.sublime-syntax#L4. I don't see any reason not to support it if people are using it and there isn't a conflict with another language

@AceofSpades5757
Copy link
Contributor Author

AceofSpades5757 commented Aug 4, 2022

@the-mikedavis Thanks. Updated it.

@the-mikedavis
Copy link
Member

(headline item: (item) @markup.heading.1) @markup.heading.marker

could be used for marking headers

AceofSpades5757 and others added 4 commits August 5, 2022 20:03
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Co-authored-by: Erasin <erasinoo@gmail.com>

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
@AceofSpades5757
Copy link
Contributor Author

(headline item: (item) @markup.heading.1) @markup.heading.marker

could be used for marking headers

Copied verbatim to end of highlighting. Attempting to test now.

@erasin
Copy link
Contributor

erasin commented Aug 6, 2022

beancount comments https://beancount.github.io/docs/beancount_language_syntax.html#comments

header like this

* Banking
** Bank of America

2003-01-05 open Assets:US:BofA:Checking
2003-01-05 open Assets:US:BofA:Savings

;; Transactions follow …

** TD Bank

2006-03-15 open Assets:US:TD:Cash

;; More transactions follow …

hightlight :

(headline item: (item) @markup.heading.1) @markup.heading.marker

In the beancount , header is like comment, It seems to borrow the org-mode syntax .
I haven't used it.

it like header mark # In markdown .

@the-mikedavis
Copy link
Member

It's a little verbose but we could highlight headers of different levels for themes that take advantage of those (like the same syntax in org or #/##/###/etc in markdown)

((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 "^\\*"))

IIRC we use up to markup.heading.6

@AceofSpades5757
Copy link
Contributor Author

It's a little verbose but we could highlight headers of different levels for themes that take advantage of those (like the same syntax in org or #/##/###/etc in markdown)

((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 "^\\*"))

IIRC we use up to markup.heading.6

This looks to be noted in the documents as well as a good use of comments. Since I still haven't had time to get up to speed on this syntax, just let me know what you want and I'd be happy to make the change.

image

@the-mikedavis
Copy link
Member

It's pretty verbose but let's go for h1-h6:

((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 "^\\*"))

@AceofSpades5757
Copy link
Contributor Author

CI seems to be having some networking issues (timeout on url request).

Otherwise, made the changes. They look good, although I hope someone makes future changes if these settings are not idiomatic to beancount.

@the-mikedavis the-mikedavis self-requested a review August 8, 2022 14:21
Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for workshopping the queries (and to you @erasin)!

@the-mikedavis the-mikedavis merged commit 4ce5a94 into helix-editor:master Aug 8, 2022
@AceofSpades5757 AceofSpades5757 deleted the beancount branch August 8, 2022 23:07
@AceofSpades5757
Copy link
Contributor Author

@erasin @the-mikedavis Yes, thank you both. I've been going through the tree-sitter documentation, but I think it'll be a while before I can make heads or tails of the scm files. Appreciate it.

thomasskk pushed a commit to thomasskk/helix that referenced this pull request Sep 9, 2022
Co-authored-by: erasin <erasinoo@gmail.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Co-authored-by: Erasin <erasinoo@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants