Tombi: TOML Language Server & Toolkit

0.9.18 · active · verified Thu Apr 16

tombi (version 0.9.18) is a comprehensive TOML Language Server and toolkit designed to provide rich editor features like auto-completion, validation, and navigation for TOML files. It focuses particularly on project configuration files such as `pyproject.toml` and `Cargo.toml`. The project is actively maintained with frequent minor releases addressing features, fixes, and dependency updates.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates how to programmatically start `tombi` as an LSP server. Most users will integrate `tombi` directly with their editor's LSP client (e.g., VS Code, NeoVim, Helix), which handles the server startup and communication automatically. Direct programmatic use for TOML *data manipulation* is not `tombi`'s primary function; for that, use dedicated TOML parsing libraries.

import subprocess
import time
import os

# This demonstrates how to start tombi as a language server process.
# In a real editor setup, your IDE would automatically handle this
# and communicate via the Language Server Protocol (LSP).

# Note: tombi is primarily an LSP server/CLI tool, not a library for
# direct programmatic TOML parsing in Python applications.
# For programmatic TOML parsing, use `tomllib` (Python 3.11+) or `toml`/`tomli`.

# Example: Start the tombi LSP server for standard I/O communication
print("Starting tombi LSP server using --stdio...")
try:
    process = subprocess.Popen(
        ['python', '-m', 'tombi', '--stdio'],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        text=True, # For text-mode communication (JSON-RPC over stdio)
        bufsize=1  # Line-buffered output for real-time communication
    )

    print("tombi LSP server started. In a real scenario, an LSP client (editor)")
    print("would now send JSON-RPC messages to stdin and read responses from stdout.")
    
    # Simulate some operational time
    time.sleep(2)
    
    print("Simulating a short run, now terminating the LSP server process.")
    process.terminate() # Attempt graceful termination
    process.wait(timeout=5) # Wait for the process to exit

    print(f"LSP server exited with return code: {process.returncode}")
    
    # Check for any error output from the server
    stderr_output = process.stderr.read()
    if stderr_output:
        print("\n--- stderr output from tombi LSP during startup/shutdown ---")
        print(stderr_output)
        print("-----------------------------------------------------------\n")

except FileNotFoundError:
    print("Error: 'tombi' command not found. Ensure tombi is installed and in PATH.")
    print("Try: pip install tombi")
except Exception as e:
    print(f"An error occurred while trying to run tombi: {e}")

view raw JSON →