Skip to main content

Crate rustledger_lsp

Crate rustledger_lsp 

Source
Expand description

Language Server Protocol implementation for Beancount.

This crate provides an LSP server for Beancount files, enabling IDE features like:

  • Real-time syntax error diagnostics
  • Autocompletion for accounts, currencies, payees
  • Go-to-definition for accounts
  • Hover information
  • Document symbols (outline view)

§Architecture

The server follows rust-analyzer’s architecture:

  • Main loop: Handles LSP messages, applies changes, dispatches requests
  • Query database: Salsa-inspired incremental computation
  • Handlers: Process LSP requests against immutable snapshots

§Example

fn main() -> std::process::ExitCode {
    rustledger_lsp::start_stdio().map(|()| std::process::ExitCode::SUCCESS)
        .unwrap_or(std::process::ExitCode::FAILURE)
}

Re-exports§

pub use ledger_state::LedgerState;
pub use ledger_state::LspConfig;
pub use ledger_state::SharedLedgerState;
pub use ledger_state::new_shared_ledger_state;
pub use main_loop::run_main_loop;
pub use main_loop::run_main_loop_with_exit_action;

Modules§

handlers
LSP request and notification handlers.
ledger_state
Ledger state management for multi-file support.
main_loop
Main event loop for the LSP server.

Structs§

Server
The LSP server.
Snapshot
An immutable snapshot of the world state.
Vfs
Virtual file system for managing open documents.

Constants§

VERSION
LSP server version.

Functions§

start_stdio
Start the LSP server using stdio transport.
uri_to_path
Convert an LSP URI to a file path.