{"id":51784719,"url":"https://github.com/hjosugi/sql-dialect-fmt","last_synced_at":"2026-07-20T16:31:30.643Z","repository":{"id":366352844,"uuid":"1275916507","full_name":"hjosugi/sql-dialect-fmt","owner":"hjosugi","description":"Opinionated Rust formatter, LSP, and browser extension toolchain for Snowflake and Databricks SQL","archived":false,"fork":false,"pushed_at":"2026-07-16T04:12:20.000Z","size":3625,"stargazers_count":0,"open_issues_count":17,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-16T05:26:49.002Z","etag":null,"topics":["chrome-extension","cli","databricks","formatter","rust","snowflake","sql","syntax-highlighting","wasm"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hjosugi.png","metadata":{"files":{"readme":"README.ja.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-21T09:58:37.000Z","updated_at":"2026-07-11T06:54:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hjosugi/sql-dialect-fmt","commit_stats":null,"previous_names":["hjosugi/snow-fmt","hjosugi/sql-dialect-fmt"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/hjosugi/sql-dialect-fmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjosugi%2Fsql-dialect-fmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjosugi%2Fsql-dialect-fmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjosugi%2Fsql-dialect-fmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjosugi%2Fsql-dialect-fmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hjosugi","download_url":"https://codeload.github.com/hjosugi/sql-dialect-fmt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjosugi%2Fsql-dialect-fmt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35693381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"ssl_error","status_checked_at":"2026-07-20T02:08:09.736Z","response_time":111,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome-extension","cli","databricks","formatter","rust","snowflake","sql","syntax-highlighting","wasm"],"created_at":"2026-07-20T16:31:29.593Z","updated_at":"2026-07-20T16:31:30.636Z","avatar_url":"https://github.com/hjosugi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- i18n: language-switcher --\u003e\n[English](README.md) | [日本語](README.ja.md)\n\n# sql-dialect-fmt\n\n[![CI](https://github.com/hjosugi/sql-dialect-fmt/actions/workflows/ci.yml/badge.svg)](https://github.com/hjosugi/sql-dialect-fmt/actions/workflows/ci.yml)\n\nSnowflake SQL と Databricks SQL のフォーマッタ＋シンタックスハイライタ（Rust 製）。`gofmt` / Prettier / Biome 流の opinionated・ほぼ設定なしの整形を目指します。\n\n整形は **無破壊・べき等** を機械的に保証します（パースできない入力は無変更で素通し、整形しても有意トークンとコメントは保存、`format(format(x)) == format(x)`）。\n\n## インストール\n\n```sh\n# crates.io から\ncargo install sql-dialect-fmt --version 1.16.2 --locked\n\n# このリポジトリから直接（`sql-dialect-fmt` バイナリが入る）\ncargo install --git https://github.com/hjosugi/sql-dialect-fmt sql-dialect-fmt\n\n# ローカルチェックアウトから\ncargo install --path crates/sql-dialect-fmt-cli\n# または: cargo build --release -p sql-dialect-fmt  →  target/release/sql-dialect-fmt\n\n# cargo-binstall 対応リリースではバイナリ取得も可能\ncargo binstall sql-dialect-fmt\n\n# Homebrew。このリポジトリを tap として使う\nbrew tap hjosugi/sql-dialect-fmt https://github.com/hjosugi/sql-dialect-fmt\nbrew install sql-dialect-fmt\n```\n\nCI では同梱の composite action またはコンテナを使えます。\n\n```yaml\n- uses: hjosugi/sql-dialect-fmt@v1\n  with:\n    args: \"sql/**/*.sql\"\n```\n\n```sh\ndocker run --rm -v \"$PWD:/work\" -w /work ghcr.io/hjosugi/sql-dialect-fmt:1.16.2 --check .\n```\n\n## 使い方\n\n```sh\nsql-dialect-fmt query.sql                 # 整形して stdout へ\nsql-dialect-fmt --write *.sql             # ファイルをその場で整形\nsql-dialect-fmt --check src/**/*.sql      # 未整形なら非ゼロ終了（CI 向け）\nsql-dialect-fmt --check --diff query.sql  # 未整形箇所を unified diff で表示\ncat query.sql | sql-dialect-fmt           # stdin → stdout\ncat query.sql | sql-dialect-fmt -         # `-` でも stdin を明示\nsql-dialect-fmt --stdin-filepath src/query.sql \u003c query.sql  # stdin に設定探索用パスを付与\n\n# オプション: --dialect snowflake|databricks / --line-width N（既定100、1以上） / --indent-width N（既定4、1以上） / --no-uppercase\n```\n\npre-commit 利用者は次の設定で `--write` または `--check` を使えます。\n\n```yaml\nrepos:\n  - repo: https://github.com/hjosugi/sql-dialect-fmt\n    rev: v1.16.2\n    hooks:\n      - id: sql-dialect-fmt\n```\n\n## Snowsight / Databricks Chrome 拡張\n\nブラウザ上で使う Chrome 拡張を `extensions/chrome` に置いています。Rust formatter を\nWebAssembly にして同梱するので、ローカルサーバは不要です。\n\n```sh\n./scripts/build-chrome-extension.sh\n```\n\nその後、Chrome の `chrome://extensions` で Developer mode を有効にし、`extensions/chrome`\nを Load unpacked してください。Snowsight または Databricks の SQL editor にフォーカスして、右下の\n`sql-dialect-fmt` ボタン、拡張アイコン、または `Alt+Shift+F` で整形できます。\n\nRelease 用の Chrome zip と VS Code VSIX はまとめて作れます。\n\n```sh\n./scripts/package-extensions.sh\n```\n\n## VS Code 拡張\n\n`editors` の VS Code 拡張は Snowflake SQL のシンタックスハイライトに加えて**整形**にも対応しています。\n`snowflake-sql` 用のフォーマッタを登録するので、**Format Document**・**Format Selection**・\n`editor.formatOnSave` がそのまま使えます。Chrome 拡張と同じく Rust formatter を WebAssembly として\n同梱し、すべてローカルで整形します（ネットワーク送信なし）。\n\n```sh\n./scripts/build-vscode-extension.sh\n```\n\n`editors/` で \u003ckbd\u003eF5\u003c/kbd\u003e を押す（または生成した VSIX をインストールする）と、`.sql` ファイルで\n**Format Document** が使えます。整形は `sqlDialectFmt.*` 設定（dialect・line width・indent width・\nkeyword casing）に従います。\n\n## 開発\n\n```sh\ncargo test --workspace\ncargo clippy --workspace --all-targets -- -D warnings\nRUSTDOCFLAGS=\"-D warnings\" cargo doc --workspace --no-deps\ncargo fmt --all --check\n```\n\n### Formatter feature flags\n\n`sql-dialect-fmt-formatter` は既定で `external-formatters` を有効にし、埋め込み\nJavaScript/Python body をそれぞれ Biome/Ruff で整形します。最小ビルドでは\nBiome/Ruff 依存を外せます。\n\n```sh\ncargo test -p sql-dialect-fmt-formatter --no-default-features\n```\n\n| feature | default | effect |\n| --- | --- | --- |\n| `external-formatters` | yes | `embedded-javascript` と `embedded-python` を有効化 |\n| `embedded-javascript` | yes | `LANGUAGE JAVASCRIPT AS $$...$$` を Biome で整形 |\n| `embedded-python` | yes | `LANGUAGE PYTHON AS $$...$$` を Ruff で整形 |\n| `embedded-brace-formatters` | no | 簡易 Java/Scala brace-aware formatter を明示的に有効化 |\n\n## 状態\n\nSnowflake は SELECT 一式・DML（INSERT/UPDATE/DELETE/MERGE）・COPY・主要 DDL/object DDL・Semantic View・CREATE PROCEDURE/FUNCTION（SQL/JavaScript/Python/Java/Scala body）までパース＋整形。JavaScript/Python body formatting は既定で有効、Java/Scala body formatting は `embedded-brace-formatters` で opt-in し、通常は verbatim 保持します。Databricks は LATERAL VIEW、Delta DDL option、VERSION/TIMESTAMP AS OF、higher-order function lambda、SQL scripting block、backtick identifier を dialect mode でサポート。LSP/semantic tokens/hover、Tree-sitter grammar、CLI、Snowsight/Databricks 用 Chrome/WASM 拡張も入っています。看板機能は **magic trailing comma**。詳細と計画は [ROADMAP.md](ROADMAP.md) を参照。\n\n## クレート構成\n\n| crate | 役割 |\n| --- | --- |\n| `sql-dialect-fmt-syntax` | `SyntaxKind`・キーワード認識・`rowan` 言語定義 |\n| `sql-dialect-fmt-lexer` | 手書きロスレス Lexer |\n| `sql-dialect-fmt-parser` | エラー回復で無停止のロスレス CST パーサ |\n| `sql-dialect-fmt-formatter` | 汎用 Doc IR エンジン ＋ SQL 整形規則 |\n| `sql-dialect-fmt-highlight` | トークン分類（シンタックスハイライト） |\n| `sql-dialect-fmt-hover` | 型・手続き・タスクの hover テキスト |\n| `sql-dialect-fmt-tree-sitter` | 同梱 Tree-sitter grammar の Rust バインディング |\n| `sql-dialect-fmt-config` | `sql-dialect-fmt.toml` の共通モデルと探索（CLI / LSP 共用） |\n| `sql-dialect-fmt-lsp` | Language Server（formatting / semanticTokens / 診断、stdio） |\n| `sql-dialect-fmt-wasm` | Chrome 拡張向けの WebAssembly bridge |\n| `sql-dialect-fmt` | CLI エントリポイント（crate path は `crates/sql-dialect-fmt-cli`） |\n\n## ライセンス\n\n0BSD. ほぼあらゆる目的で利用・複製・変更・配布できます。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjosugi%2Fsql-dialect-fmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhjosugi%2Fsql-dialect-fmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjosugi%2Fsql-dialect-fmt/lists"}