Skip to content

Add query formatting from the leader menu - #309

Merged
Maxteabag merged 1 commit into
mainfrom
feat/issue-278-query-format
Aug 23, 2026
Merged

Add query formatting from the leader menu#309
Maxteabag merged 1 commit into
mainfrom
feat/issue-278-query-format

Conversation

@Maxteabag

Copy link
Copy Markdown
Owner

Summary

  • add an undoable SQL formatting action powered by the existing sqlparse dependency
  • expose it as <space>p / Format Query in the leader menu
  • uppercase SQL keywords, reindent clauses and lists, and add operator spacing
  • preserve comments, strings, placeholders, semicolon boundaries, and sqlit’s two-blank-line boundaries
  • remap the cursor beside the same SQL token after whitespace changes
  • expose the action in generated help and the customizable keymap template

Fixes #278.

Why sqlparse

sqlparse is already a sqlit dependency, BSD licensed, lightweight, and non-validating. It formats without adding a new runtime or external executable. It is intentionally treated as a generic formatter rather than a dialect validator.

Validation

  • 18 dedicated formatting unit/UI regressions
  • 81 focused formatting, leader, state, and keymap tests passed
  • full unit and UI suite: 1,477 passed, 2 skipped
  • real Textual <space>p dispatch, undo, and cursor-token tests
  • PostgreSQL JSON operators, MSSQL bracketed identifiers/hints, placeholders, comments, strings, multiple statements, and idempotence covered
  • Ruff and structured autoreview: clean

This PR is intentionally left open for manual review.

@Maxteabag
Maxteabag merged commit 69e4a35 into main Aug 23, 2026
21 checks passed
@Maxteabag
Maxteabag deleted the feat/issue-278-query-format branch August 23, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query indentation/auto-format

1 participant