Taplo TOML Toolkit

repository·master·Indexed 25 days ago

https://github.com/tamasfe/taplo

A comprehensive TOML v1.0.0 toolkit providing parsing, decoding, and formatting capabilities. It includes a CLI for linting and formatting, a Language Server Protocol (LSP) implementation for editor intelligence, and language bindings for Rust, WASM, and JavaScript (@taplo/cli, @taplo/lib, @taplo/lsp). The toolkit also powers the even-better-toml VS Code extension, offering features like JSON Schema association, semantic highlighting, and symbol navigation.

Tokens
29.7K
Snippets
38
Records
223
Agent score
81%

What's inside Taplo

  1. Overview of even-better-toml features

    master

    The even-better-toml extension (backed by Taplo) provides comprehensive TOML support in VS Code, including:

    • TOML 1.0.0 Support: Full support for the latest TOML specification.
    • Syntax Highlighting: TextMate-based highlighting with support for custom scopes (tables, arrays, etc.).
    • Semantic Highlighting: Enhanced highlighting for inline tables and arrays.
    • Validation: Real-time error checking and validation.
    • Folding: Ability to fold arrays, multi-line strings, top-level tables, and comments.
    • Navigation: A symbol tree for navigating TOML structures, even when tables are out of order.
    • Refactoring: Support for renaming symbols.
    • Formatting: Conservative default formatting with additional configurable features.
    • Schema Support: Completion and validation using JSON Schemas.
    • Commands: Built-in commands for JSON <-> TOML conversion.
  2. Overview of Taplo TOML toolkit

    master
    Taplo is a toolkit designed for TOML v1.0.0. It provides various tools including a CLI, LSP (Language Server Protocol) support, and library bindings for different environments (Rust, WASM, JavaScript). It is intended to assist with TOML parsing, decoding, and formatting.
  3. Use @taplo/lib for TOML formatting and validation

    master

    @taplo/lib is a JavaScript library that provides high-level functions for common TOML tasks. Use this package if you need to format or validate TOML strings within a JavaScript/TypeScript environment.

    Limitations: This library is designed for general use and does not allow for deep inspection of the TOML Abstract Syntax Tree (AST) or other low-level document structures. For AST manipulation, you may need to look into other parts of the Taplo ecosystem.

  4. Use Taplo CLI for TOML validation, formatting, and querying

    master

    Taplo CLI is a comprehensive command-line tool designed for working with TOML files. It provides three primary capabilities:

    1. Validation: Ensure TOML documents are syntactically correct and conform to schemas.
    2. Formatting: Automatically format TOML files for consistent style.
    3. Querying: Extract specific data from TOML documents using a syntax similar to jq.
  5. Use the Rust unit test generator for TOML files

    master
    The util/test-gen tool is a utility designed to automate the creation of Rust unit tests by using TOML files as the source of truth. It reads TOML data and generates corresponding Rust test code to ensure data integrity and schema compliance.
  6. Use @taplo/cli JavaScript wrapper

    master
    @taplo/cli is a JavaScript wrapper for the Taplo TOML CLI tool. It allows you to interact with Taplo's TOML capabilities within a JavaScript/Node.js environment. For full documentation, configuration details, and advanced usage, refer to the official Taplo website.
  7. Use @taplo/lsp as a JavaScript wrapper for Taplo CLI

    master
    @taplo/lsp provides a JavaScript wrapper around the Taplo TOML CLI tool. This allows developers to integrate Taplo's TOML capabilities (such as linting, formatting, and validation) into JavaScript-based environments or workflows that interact with the Taplo CLI.
  8. Use @taplo/lib as a JavaScript wrapper for Taplo

    master
    @taplo/lib provides a JavaScript interface for the Taplo TOML library. It allows developers to integrate Taplo's TOML parsing, formatting, and validation capabilities directly into JavaScript or TypeScript applications. For detailed documentation on specific API methods and configuration options, refer to the official Taplo website.
  9. What is Taplo Core?

    master

    The taplo crate is a low-level, generic-purpose TOML library written in Rust. It provides the fundamental building blocks for TOML manipulation, including:

    • Parsing: Converting TOML documents into an Abstract Syntax Tree (AST) and a Document Object Model (DOM).
    • Formatting: Exposing functionality to format TOML documents.

    It is intended as a foundational library for other tools (like CLI tools or LSP servers) rather than a high-level end-user application.

  10. What is LSP Async Stub

    master

    LSP Async Stub is a library providing utilities and a basic server stub designed for asynchronous Language Server Protocol (LSP) communication using JSON RPC. It is primarily used by taplo-lsp to simplify the implementation of an LSP server.

    Key features include:

    • Async Handlers: The stub expects asynchronous handlers for incoming messages.
    • Message Context: Handlers receive the message parameters and a context object used for shared data, cancellation, and sending requests or notifications back to the client.
    • Spec Compliance: It automatically handles invalid messages, the initialization process, and the teardown process according to the LSP specification.