darold / darold/pgFormatter

Proposal: optional matching-parenthesis line breaks

Open
#417 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PLpgSQL
Stars
2k
Forks
121
Avg merge
4d 21h
Merged PRs (30d)
7

Description

Would you be open to an option that puts a closing parenthesis on its own line when the formatted content after the opening parenthesis starts on a new line?

I find this makes the end of longer column lists and subqueries easier to spot. For example, with -B and all other formatting options at their defaults:

INSERT INTO widgets (
    id,
    label)
SELECT
    1,
    2;

With the proposed option:

INSERT INTO widgets (
    id,
    label
)
SELECT
    1,
    2;

The closing parenthesis would align with the line containing its opening parenthesis. Nested pairs would follow the same rule independently, and content that starts on the same line as ( would keep its current layout.

My suggested name is --matching-paren-newline, disabled by default since this is a style preference. I’d welcome your thoughts on both the name and the behavior.

I’ve put together an implementation in #415 to make the proposal concrete. Feel free to close that PR if this option isn’t something you’d like to support.

Thanks for maintaining pgFormatter!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review pull request #415 and the existing -B formatting behavior first. Validate the proposed --matching-paren-newline option against the issue’s examples, including nested pairs and content beginning on the same line; done means the option is disabled by default and produces the specified aligned closing-parenthesis layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, sql
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.