Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
18 changes: 18 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

libpgfmt is a Rust library for formatting PostgreSQL-specific SQL and PL/pgSQL.

## Build Commands

```sh
cargo build
cargo test
cargo test <test_name> # run a single test
cargo clippy # lint
cargo fmt --check # check formatting
cargo fmt # auto-format
```
248 changes: 248 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "libpgfmt"
version = "0.1.0"
edition = "2024"
description = "A Rust library for formatting PostgreSQL SQL and PL/pgSQL"
license = "BSD-3-Clause"
repository = "https://github.com/gmr/libpgfmt"
keywords = ["postgresql", "sql", "formatter", "plpgsql"]
categories = ["text-processing", "development-tools"]

[dependencies]
tree-sitter = "0.26"
tree-sitter-postgres = "0.1"

[dev-dependencies]
pretty_assertions = "1"
21 changes: 21 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use std::fmt;

/// Errors that can occur during formatting.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum FormatError {
/// The tree-sitter parser could not be initialized.
Parser(String),
/// The input SQL contains a syntax error.
Syntax(String),
}

impl fmt::Display for FormatError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FormatError::Parser(msg) => write!(f, "Parser error: {msg}"),
FormatError::Syntax(msg) => write!(f, "Syntax error: {msg}"),
}
}
}

impl std::error::Error for FormatError {}
Loading