Align the formatter defaults and layout with the hand-formatted reference procedures in dist/examples so a clean `pgtidy fmt` produces the house style. config.Default(): - align_param_types: false (no type-column alignment in param lists) - plpgsql_declare_align_type / plpgsql_declare_align_eq: true Formatter: - routine header: leading-comma params at column 0, first param at one indent, RETURNS/LANGUAGE/volatility/SECURITY each indented one level - %type / %rowtype printed tight (isPctTypeBoundary) - DECLARE = / := / DEFAULT column padded only to the widest declaration that carries an assignment - WHERE continuations in body UPDATE/DELETE: AND/OR aligned with WHERE - EXCEPTION aligned to its enclosing BEGIN; column-0 comment continuations kept flush-left Safety gate: - SemanticallyEqual tolerates CRLF vs LF inside string literals (normNL); the formatter re-emits all layout with st.Newline, so a \r\n inside a multi-line string literal is normalisation, not a code change. This was why action_init and event_exec_func previously refused to format. Corpus: - add the four CRLF reference files as idempotence/safety fixtures - regenerate test_a and test_mm_proc goldens FOR...LOOP body indentation keeps the existing +1 convention (LOOP aligned with FOR); the dist/examples use +2, so loop-body regions differ by whitespace only.
69 lines
3.0 KiB
YAML
69 lines
3.0 KiB
YAML
# PgTidy house style — all fields with their default values.
|
|
# Place as .pgtidy.yaml in your project root (or any parent directory).
|
|
# Any field you omit keeps its default.
|
|
|
|
# --- Core ---
|
|
|
|
indent: " " # One indentation level (two spaces).
|
|
newline: "\n" # Line terminator emitted by the formatter.
|
|
|
|
# --- Casing ---
|
|
# upper | lower | preserve
|
|
|
|
keyword_case: upper # SQL keywords (SELECT, FROM, WHERE, …)
|
|
ident_case: lower # Unquoted identifiers (column/variable names)
|
|
type_case: lower # Built-in type names (text, integer, boolean, …)
|
|
alias_case: lower # Token immediately following AS in SELECT / FROM
|
|
builtin_case: lower # Built-in function names (COALESCE, MAX, NOW, …)
|
|
custom_type_case: lower # User-defined / domain types not in the built-in set
|
|
|
|
# --- Query layout ---
|
|
|
|
commas: leading # leading → ,col | trailing → col,
|
|
|
|
align_columns: false # Pad SELECT list items so values align vertically
|
|
align_line_comments: false # Align trailing -- comments within a block
|
|
select_align_as: false # Pad between expression and AS keyword in SELECT list
|
|
set_align_equal: false # Align = in UPDATE SET list
|
|
indent_join: false # Extra indentation for JOIN … ON lines
|
|
join_indent_size: 1 # Number of extra indent levels for JOINs
|
|
|
|
# always | when_long | never
|
|
where_wrap: always # Each AND/OR condition on its own line
|
|
|
|
where_and_or_indent: true # AND/OR indented one level under WHERE
|
|
|
|
# --- Subqueries ---
|
|
# same_line | new_line
|
|
|
|
subquery_opening: same_line # Opening ( placement
|
|
subquery_content: new_line # Content indentation inside parens
|
|
subquery_closing: new_line # Closing ) placement
|
|
subquery_space_before_paren: false # Space before ( in subqueries
|
|
|
|
# --- INSERT ---
|
|
|
|
insert_collapse_values: true # Fold multiple VALUES rows onto fewer lines
|
|
|
|
# --- Routines (functions / procedures) ---
|
|
|
|
align_param_types: false # Pad param names so type column aligns across all params
|
|
routine_as_wrap: true # Newline before AS $$ (false = keep AS on same line)
|
|
|
|
# --- PL/pgSQL body ---
|
|
|
|
plpgsql_max_blank_lines: 1 # Max consecutive blank lines in body
|
|
plpgsql_declare_align_type: true # Align type column in DECLARE block
|
|
plpgsql_declare_align_eq: true # Align := / = in DECLARE block (padded to the widest assigned declaration)
|
|
plpgsql_if_then_newline: true # THEN on its own line (false = same line as condition)
|
|
plpgsql_loop_collapse: true # Collapse empty loop bodies to one line
|
|
|
|
# --- Expressions ---
|
|
|
|
binary_op_align: false # Align =, <>, || etc. vertically in WHERE/expression lists
|
|
space_after_comma_in_calls: false # Space after , in function calls: func(a, b)
|
|
case_when_wrap: false # Each WHEN … THEN on its own line
|
|
case_end: new_line # END placement: same_line | new_line
|
|
case_collapse: false # Collapse short CASE expressions to one line
|
|
record_space_before_paren: false # Space before ( in ROW(…) / record constructors
|