Skip to content

Type to search extensions

hledger

v0.1.3

Plain-text accounting with hledger: syntax highlighting and LSP support

Updated 7 months ago
396 downloads 6 stars Repository ↗

hledger-zed

Zed extension for hledger journal files with LSP integration.

Features

  • LSP support via hledger-lsp:
    • Syntax highlighting via semantic tokens
    • Autocompletion for accounts and commodities
    • Hover information
    • Diagnostics for unbalanced transactions
    • Go to definition
    • Document formatting
  • Support for .journal, .hledger, .ledger, and .rules files

Installation

From Zed Extensions

  1. Open Zed
  2. Go to Extensions (Cmd+Shift+X on macOS)
  3. Search for "hledger"
  4. Click Install

Manual Installation

  1. Clone this repository
  2. Open Zed and go to Extensions
  3. Click "Install Dev Extension" and select the cloned directory

LSP Binary

The extension resolves hledger-lsp in this order:

  1. A path configured with lsp.hledger-lsp.binary.path in your Zed settings
  2. The latest hledger-lsp binary from GitHub Releases
  3. A cached binary or hledger-lsp from PATH if the latest release cannot be fetched or downloaded

If you prefer to install it manually:

# Using Go
go install github.com/juev/hledger-lsp@latest

# Or download from releases
# https://github.com/juev/hledger-lsp/releases

After manual installation, set lsp.hledger-lsp.binary.path explicitly. Binaries found on PATH are used as a fallback when automatic download is unavailable.

Configuration

Configure the LSP in your Zed settings.json:

{
  "lsp": {
    "hledger-lsp": {
      "binary": {
        "path": "/custom/path/to/hledger-lsp"
      },
      "initialization_options": {
        "hledger": {
          "features": {
            "hover": true,
            "completion": true,
            "formatting": true,
            "diagnostics": true,
            "semanticTokens": true,
            "codeActions": true,
            "foldingRanges": true,
            "documentLinks": true,
            "workspaceSymbol": true,
            "inlineCompletion": true,
            "codeLens": false
          },
          "completion": {
            "maxResults": 50,
            "fuzzyMatching": true,
            "showCounts": true,
            "includeNotes": true
          },
          "diagnostics": {
            "undeclaredAccounts": true,
            "undeclaredCommodities": true,
            "unbalancedTransactions": true,
            "balanceTolerance": 0.0
          },
          "formatting": {
            "indentSize": 4,
            "alignAmounts": true,
            "minAlignmentColumn": 40
          },
          "cli": {
            "enabled": true,
            "path": "hledger",
            "timeout": 30000
          },
          "limits": {
            "maxFileSizeBytes": 10485760,
            "maxIncludeDepth": 50
          }
        }
      }
    }
  }
}

Settings Reference

Features
Setting Default Description
features.hover true Hover information
features.completion true Completions
features.formatting true Document formatting
features.diagnostics true Diagnostics
features.semanticTokens true Semantic tokens
features.codeActions true Code actions
features.foldingRanges true Folding ranges for transactions and directives
features.documentLinks true Clickable links for include directives
features.workspaceSymbol true Workspace symbol search
features.inlineCompletion true Ghost text completions for transaction templates
features.codeLens false Balance check indicators on transactions
Completion
Setting Default Description
completion.maxResults 50 Maximum number of completion items
completion.fuzzyMatching true Enable fuzzy matching
completion.showCounts true Show usage counts in completion details
completion.includeNotes true Include notes in payee completions
Diagnostics
Setting Default Description
diagnostics.undeclaredAccounts true Report undeclared accounts
diagnostics.undeclaredCommodities true Report undeclared commodities
diagnostics.unbalancedTransactions true Report unbalanced transactions
diagnostics.balanceTolerance 0.0 Tolerance for balance checks (0 = exact)
Formatting
Setting Default Description
formatting.indentSize 4 Number of spaces for posting indent
formatting.alignAmounts true Align amounts across postings
formatting.minAlignmentColumn 40 Minimum column for amount alignment (0 = auto)
CLI
Setting Default Description
cli.enabled true Enable hledger CLI integration
cli.path "hledger" Path to hledger executable
cli.timeout 30000 CLI command timeout in milliseconds
Limits
Setting Default Description
limits.maxFileSizeBytes 10485760 Maximum journal file size (bytes)
limits.maxIncludeDepth 50 Maximum include depth for recursive loading

Syntax Highlighting

Basic syntax highlighting is provided by the built-in tree-sitter grammar and works out of the box with any Zed theme — no LSP required.

For enhanced highlighting, enable semantic tokens from hledger-lsp by adding the following to your settings.json:

{
  "languages": {
    "hledger": {
      "semantic_tokens": "full"
    },
    "hledger-rules": {
      "semantic_tokens": "full"
    }
  }
}

Supported File Extensions

  • .journal
  • .hledger
  • .ledger
  • .rules (CSV import rules)

Development

Prerequisites

  • Rust
  • wasm32-wasip1 target: rustup target add wasm32-wasip1

Building

cargo build --target wasm32-wasip1 --release

Testing Locally

  1. Build the extension
  2. Open Zed → Extensions → Install Dev Extension
  3. Select this directory
  4. Open a .journal file to test

License

MIT

ZedExt An unofficial community project. Not affiliated with Zed Industries.

Data from Zed’s extension registry and GitHub · updated