repos:
  # Rust-specific hooks
  - repo: local
    hooks:
      - id: cargo-fmt
        name: cargo fmt
        entry: cargo fmt -- --check
        language: system
        files: \.rs$
        pass_filenames: false
      - id: cargo-clippy
        name: cargo clippy
        entry: cargo clippy --all-features -- -D warnings
        language: system
        files: \.(rs|toml)$
        pass_filenames: false
      - id: cargo-test
        name: cargo test
        entry: cargo test --all-features
        language: system
        files: \.(rs|toml)$
        pass_filenames: false
      - id: cargo-deny
        name: cargo deny
        entry: cargo deny check
        language: system
        files: Cargo\.(toml|lock)$
        pass_filenames: false

  # General code quality hooks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-toml
      - id: check-json
      - id: check-merge-conflict
      - id: check-added-large-files
        args: ['--maxkb=500']
      - id: detect-private-key
      - id: mixed-line-ending
        args: ['--fix=lf']

  # Spell checking
  - repo: https://github.com/crate-ci/typos
    rev: v1.31.1
    hooks:
      - id: typos
        args: [--format=brief]
