-
-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Add a tree-sitter-based diagnostic provider to complement the existing beancount Python diagnostics, providing real-time error detection while editing.
Motivation
Currently, diagnostics are provided via beancount Python integration which may not catch all syntax errors in real-time. A tree-sitter diagnostic provider would offer:
- Real-time syntax error detection while typing
- Transaction balance validation - detect when current sum of transaction doesn't balance
- Structural validation - missing required fields, malformed entries
- Faster feedback - no need to invoke Python beancount for basic syntax issues
Proposed Features
Core Diagnostics
- Syntax errors from tree-sitter parsing
- Unbalanced transactions (sum != 0)
- Missing transaction descriptions
- Invalid account names (wrong format/structure)
- Date format validation
- Currency/commodity format validation
Advanced Diagnostics
- Detect incomplete postings (missing amounts)
- Flag suspicious patterns (unusual account combinations)
- Validate posting structure (account + amount pairs)
- Check for required metadata on certain transaction types
Implementation Plan
- Create diagnostic provider module (
crates/lsp/src/providers/diagnostics_treesitter.rs) - Integrate with existing diagnostic system in
handlers.rs - Add tree-sitter query patterns for common error conditions
- Implement transaction balance checking using tree-sitter AST traversal
- Add configuration options to enable/disable specific diagnostic types
Benefits
- Immediate feedback without waiting for beancount processing
- Better developer experience while editing
- Complement existing Python-based diagnostics
- Foundation for more advanced real-time features
Related
- Existing diagnostics:
python/bean_check.py - Tree-sitter integration: already used for parsing
- LSP diagnostics handler:
crates/lsp/src/handlers.rs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request