pawnfmt

module
v1.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: MIT

README

pawnfmt

A fast, deterministic formatter for Pawn (SA-MP / open.mp) source: .pwn and .inc files.

Documentation

These docs cover the parts of pawnfmt people usually need once they move past the quick start:

For a ready-to-edit config file, run:

pawnfmt --init-config

That writes a commented pawnfmt.toml with every option set to its default value.

Install

Download a prebuilt binary from GitHub Releases. Release archives are built for Linux, macOS, and Windows on amd64 and arm64.

If you already have Go installed, you can also install from source:

go install github.com/pawnkit/pawnfmt/cmd/pawnfmt@latest

Use a version tag instead of latest when you want reproducible CI builds:

go install github.com/pawnkit/pawnfmt/cmd/pawnfmt@<tag>

Usage

Format files in place:

pawnfmt --write gamemodes includes

Check formatting without changing files:

pawnfmt --check gamemodes includes

Print a diff:

pawnfmt --diff script.pwn

Editor / CI Integration

Call pawnfmt directly from your editor or CI:

pawnfmt --check gamemodes includes

For Git hooks, choose the hook manager that fits your project:

Lefthook:

pre-commit:
  jobs:
    - run: pawnfmt --write {staged_files}
      glob: "*.{pwn,inc}"
      stage_fixed: true

prek:

repos:
  - repo: local
    hooks:
      - id: pawnfmt
        name: pawnfmt
        entry: pawnfmt --write
        language: system
        files: \.(pwn|inc)$

pre-commit:

- repo: https://github.com/pawnkit/pawnfmt
  rev: <tag>
  hooks:
    - id: pawnfmt

A plain Git hook also works if you do not want a hook manager:

#!/bin/sh
pawnfmt --check gamemodes includes

Save it as .git/hooks/pre-commit and make it executable.

Directories

Path Synopsis
cmd
corpus-report command
Command corpus-report runs the formatter against the real-world corpus and reports results.
Command corpus-report runs the formatter against the real-world corpus and reports results.
pawnfmt command
Command pawnfmt is a Pawn (SA-MP/open.mp) source code formatter.
Command pawnfmt is a Pawn (SA-MP/open.mp) source code formatter.
internal
bench
Package bench generates synthetic Pawn sources for benchmarking.
Package bench generates synthetic Pawn sources for benchmarking.
check
Package check runs formatter correctness checks used by the corpus report.
Package check runs formatter correctness checks used by the corpus report.
config
Package config defines pawnfmt's configuration schema, defaults, and loading.
Package config defines pawnfmt's configuration schema, defaults, and loading.
doc
Package doc implements a Wadler/Prettier-style pretty-printing IR.
Package doc implements a Wadler/Prettier-style pretty-printing IR.
format
Package format renders a parsed Pawn source file to formatted output.
Package format renders a parsed Pawn source file to formatted output.
printer
Package printer renders a doc.
Package printer renders a doc.
trivia
Package trivia scans source lines for blank/comment/directive/disabled-region info.
Package trivia scans source lines for blank/comment/directive/disabled-region info.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL