Syntax Highlighting for VSCode and Sublime Text 3

356 views
Skip to first unread message

Scott Carpenter

unread,
Oct 23, 2019, 2:16:35 PM10/23/19
to Ledger
I recently switched from Sublime Text to VSCode and created a plugin for the textmate language grammar for journal files (.ledger and .ldg). I'm still maintaining the sublime syntax file, too. All the things are here:


The rules are targeted at standard account roots: expenses, assets, liabilities, income, and equity. (Or one letter aliases of same, except for equity.)

I think it looks nice and colorful:

ledger-syntax-highlighting-0.png


In Sublime Text, I originally used scopes that had these colors with a Monokai Dark theme, but there are settings included in repo for both ST3 and vscode to match what is shown here and in the syntax readme.

It handles tags, balance assertions, balance assignments, and virtual postings. I don't use a lot of ledger features and make no promises on how it does for more complicated journal files, but I'd be open to attempting updates if given examples.


David Glasser

unread,
Oct 23, 2019, 2:31:42 PM10/23/19
to ledge...@googlegroups.com
Neat!

I've recently started using VSCode more for TypeScript/TSX as even with lsp-mode it's a lot better than Emacs, but it's difficult to live in multiple editing environments (not to mention needing IntelliJ for JVM work), so I've considered trying to just entirely move off Emacs, and ledger-mode is one of the big things I'd lose. I've see https://github.com/mariosangiorgio/vscode-ledger but it's not maintained; it does look pretty straightforward to extend to add more autocompletion etc though.  I am also worried about missing ledger-mode's reconcile mode, but it looks like your ledgerbil does something like that.  (One addition I might make if I try it out: a version of the "mark" command that lets me type an amount and, if there's a unique unreconciled transaction with that amount, marks it.  Would make running down a long credit card bill easier... just type the numbers as they come!)

--dave

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/725d0f46-484c-49c4-acba-84c5815973bb%40googlegroups.com.


--

Scott Carpenter

unread,
Oct 23, 2019, 4:55:08 PM10/23/19
to Ledger
Thanks for the feedback, David. I'll give some thought to that mark enhancement!

I noticed Mario's plugin, too, and it still works pretty well. I decided to keep things lighter in the editor for now with just doing syntax highlighting, but the autocompletion was working well on small files. I didn't end up trying it on my big journal file so not sure how it would do there.
To unsubscribe from this group and stop receiving emails from it, send an email to ledge...@googlegroups.com.

Scott Carpenter

unread,
Oct 23, 2019, 10:00:46 PM10/23/19
to Ledger
I added your mark enhancement. I can see that being more convenient. (Now to wait with great anticipation for my next statement.) :-)

On Wednesday, October 23, 2019 at 1:31:42 PM UTC-5, David Glasser wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to ledge...@googlegroups.com.

Alen Šiljak

unread,
Apr 27, 2020, 6:53:16 AM4/27/20
to Ledger
Scott, I guess your extension is not available through the Extensions menu in VSCode? It would be very convenient to have it there and more people would find it by default.
Reply all
Reply to author
Forward
0 new messages