ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Beancount​Autocomplete

by rhydlewis ST3 New

No description provided

Details

Installs

  • Total 0
  • Win 0
  • Mac 0
  • Linux 0
Feb 10 Feb 9 Feb 8 Feb 7 Feb 6 Feb 5 Feb 4 Feb 3 Feb 2 Feb 1 Jan 31 Jan 30 Jan 29 Jan 28 Jan 27 Jan 26 Jan 25 Jan 24 Jan 23 Jan 22 Jan 21 Jan 20 Jan 19 Jan 18 Jan 17 Jan 16 Jan 15 Jan 14 Jan 13 Jan 12 Jan 11 Jan 10 Jan 9 Jan 8 Jan 7 Jan 6 Jan 5 Jan 4 Jan 3 Jan 2 Jan 1 Dec 31 Dec 30 Dec 29 Dec 28
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Beancount Autocomplete

A Sublime Text plugin that provides intelligent autocomplete for Beancount account names.

Features

  • Smart Account Discovery: Automatically scans your Beancount file for account definitions
  • Cached Performance: Intelligently caches accounts and only reloads when your Beancount file changes
  • Instant Completions: Get autocomplete suggestions for all your accounts as you type
  • Hierarchical Account Support: Handles Beancount's hierarchical account structure (e.g., Assets:Bank:Checking, Expenses:Food:Groceries)

Installation

Via Package Control (Recommended)

  1. Open the Command Palette (Cmd+Shift+P on macOS, Ctrl+Shift+P on Windows/Linux)
  2. Select “Package Control: Install Package”
  3. Search for “BeancountAutocomplete”
  4. Press Enter to install

Manual Installation

  1. Clone this repository into your Sublime Text Packages directory:

macOS:

cd ~/Library/Application\ Support/Sublime\ Text/Packages/
   git clone https://github.com/rhydlewis/BeancountAutocomplete.git

Linux:

cd ~/.config/sublime-text/Packages/
   git clone https://github.com/rhydlewis/BeancountAutocomplete.git

Windows:

cd %APPDATA%\Sublime Text\Packages\
   git clone https://github.com/rhydlewis/BeancountAutocomplete.git
  1. Restart Sublime Text

Configuration

To use this plugin, you must configure the path to your main Beancount file.

Global Configuration

  1. Open Sublime Text preferences: Preferences → Settings
  2. Add the following configuration:
{
    "beancount_file": "/absolute/path/to/your/accounts.beancount"
}

Project-Specific Configuration

For project-specific settings, add to your .sublime-project file:

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {
        "beancount_file": "/absolute/path/to/your/accounts.beancount"
    }
}

Important: The beancount_file path must be an absolute path, not a relative path.

Usage

Once configured, the plugin works automatically:

  1. Open any file in Sublime Text
  2. Start typing an account name (e.g., Assets:)
  3. Autocomplete suggestions will appear showing all matching accounts
  4. Press Tab or Enter to insert the selected account

The plugin specifically looks for open directives in your Beancount file to build the list of valid accounts:

Error: language “beancount” is not supported
2020-01-01 open Assets:Bank:Checking
2020-01-01 open Expenses:Food:Groceries
2020-01-01 open Income:Salary

How It Works

  • The plugin scans your configured Beancount file for account definitions
  • Accounts are cached in memory for performance
  • The cache automatically refreshes when your Beancount file is modified
  • Only accounts from open directives are included for cleaner suggestions

Requirements

  • Sublime Text 3 or 4
  • A Beancount ledger file

Development

Local Deployment

For local development and testing, use the included deployment script:

./deploy.sh

This script: - Detects your operating system (macOS, Linux, Windows) - Copies beancount_autocomplete.py to Sublime Text's User packages directory - Creates a timestamped backup of any existing version - Works across all platforms

After deployment: 1. Restart Sublime Text or reload the plugin via Command Palette (Ctrl+Shift+P → “Plugin Development: Reload Plugin”) 2. Test your changes in a Beancount file

Running Tests

The plugin includes a comprehensive test suite using Python's unittest framework. To run the tests:

python3 -m unittest tests.test_beancount_autocomplete -v

The tests cover: - Account name regex pattern matching - Loading accounts from Beancount files - File caching behavior - Completion filtering by prefix - Case-insensitive matching - Error handling for missing files

All tests use mocks for Sublime Text's API, so they can run independently without Sublime Text installed.

Troubleshooting

No completions appear

  1. Verify your beancount_file setting points to the correct file path
  2. Check that the file exists and is readable
  3. Ensure your Beancount file contains open directives
  4. View the Sublime Text console (View → Show Console) for any error messages

Completions are outdated

The plugin caches accounts for performance. If you've added new accounts, they should appear automatically after saving your Beancount file. If not, restart Sublime Text.

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About Beancount

Beancount is a double-entry bookkeeping system that uses plain text files. Learn more at beancount.github.io.