Skip to content

Instantly share code, notes, and snippets.

@lifepillar
Created January 11, 2012 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lifepillar/1597432 to your computer and use it in GitHub Desktop.
Save lifepillar/1597432 to your computer and use it in GitHub Desktop.
Ledger (http://ledger-cli.org) syntax coloring for TextWrangler
To install, simply copy Ledger.plist into ~/Library/Application Support/TextWrangler/Language Modules (create the directory if it does not exist). Then, restart TextWrangler. Note that syntax coloring works better when the currency goes /after/ the amount.
Take a look at the comments inside Ledger.plist if you want to customize it.
<!-- Gleefully brought to you by Lifepillar -->
<!-- Version 1.0.1 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BBEditDocumentType</key>
<string>CodelessLanguageModule</string>
<key>BBLMColorsSyntax</key> <true/>
<key>BBLMIsCaseSensitive</key> <false/>
<key>BBLMLanguageCode</key>
<string>Ldgr</string>
<key>BBLMLanguageDisplayName</key>
<string>Ledger</string>
<key>BBLMScansFunctions</key>
<true/>
<key>BBLMSuffixMap</key>
<array>
<dict>
<key>BBLMLanguageSuffix</key>
<string>.ledger</string>
</dict>
</array>
<key>BBLMCanSpellCheckCodeRuns</key>
<false/>
<key>Language Features</key>
<dict>
<key>Identifier and Keyword Characters</key>
<string><![CDATA[!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]]></string>
<key>Comment Pattern</key>
<string><![CDATA[(?x:
(?>
(?> [;\*] .* $ ) |
(?> @comment(?s:.*?)(?>@end\scomment|\z) )
)
)]]></string>
<!-- Adapt currencies as needed (I'm too lazy to add them all) -->
<key>String Pattern</key>
<string><![CDATA[(?x:
(?> -?\d+([,\.]\d+)*\s*(EUR|USD|CAD|AUD) ) |
(?> \$\s*-?\d+([,\.]\d+)*[\s\z] ) |
(?> \d+[:\/\-]\d+[:\/\-]\d+ )
)]]></string>
<key>Function Pattern</key>
<string><![CDATA[(?x:
(?P<function>(?P<function_name>(^\d+.+$)))
)]]></string>
<key>Skip Pattern</key>
<string><![CDATA[(?x:(?P>comment))]]></string>
</dict>
<key>BBLMKeywordList</key>
<array>
<string>Day</string>
<string>Week</string>
<string>Month</string>
<string>Quarter</string>
<string>Year</string>
<string>Days</string>
<string>Weeks</string>
<string>Months</string>
<string>Quarters</string>
<string>Years</string>
<string>Daily</string>
<string>Weekly</string>
<string>Biweekly</string>
<string>Monthly</string>
<string>Bimonthly</string>
<string>Quarterly</string>
<string>Yearly</string>
<string>Every</string>
<string>January</string>
<string>February</string>
<string>March</string>
<string>April</string>
<string>May</string>
<string>June</string>
<string>July</string>
<string>August</string>
<string>September</string>
<string>October</string>
<string>November</string>
<string>December</string>
<string>Jan</string>
<string>Feb</string>
<string>Mar</string>
<string>Apr</string>
<string>May</string>
<string>Jun</string>
<string>Jul</string>
<string>Aug</string>
<string>Sep</string>
<string>Oct</string>
<string>Nov</string>
<string>Dec</string>
<string>This</string>
<string>Next</string>
<string>Last</string>
<string>In</string>
<string>From</string>
<string>Since</string>
<string>To</string>
<string>Until</string>
<!-- Commmand directives -->
<string>!include</string>
<string>!account</string>
<string>!end</string>
<!-- The following are not Ledger keywords -->
<!-- Feel free to remove them, modify them or add more -->
<string>Accounts</string>
<string>Assets</string>
<string>Card</string>
<string>Cash</string>
<string>Checking</string>
<string>Credit</string>
<string>Debit</string>
<string>Equity</string>
<string>Expenses</string>
<string>Income</string>
<string>Interest</string>
<string>Liabilities</string>
<string>Payable</string>
<string>Receivable</string>
<string>Savings</string>
<string>Taxes</string>
</array>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment