ITADN
xo/usql/Issues

Feature Request: pgcli-style Autocompletion & Syntax Highlighting

#553ClosedGourangaDasSamrat 创建于 2026-03-14
### Summary Add interactive autocompletion and syntax highlighting to `usql`, similar to what `pgcli`, `mycli`, and `litecli` offer — but for all supported databases through a single tool. --- ### Motivation `usql` is uniquely powerful because it handles multiple databases with one interface. However, for users who work across Postgres, MySQL, SQLite, and others daily, the lack of autocompletion is the single biggest quality-of-life gap compared to database-specific tools like `pgcli`. Currently, the only alternative is maintaining separate installs of `pgcli`, `mycli`, and `litecli` — defeating the purpose of having a unified tool. --- ### Requested Features #### 1. SQL Keyword Completion - Complete `SELECT`, `WHERE`, `JOIN`, `GROUP BY`, etc. as you type - Case-insensitive matching #### 2. Schema-aware Completion - Table names from the connected database - Column names based on context (after `SELECT`, `WHERE`, etc.) - Function names (e.g. `COUNT`, `NOW`, `COALESCE`) #### 3. Inline Hints (ghost text) - Show the most likely completion to the right of the cursor - Dimmed/muted color, confirmed with `→` or `Tab` - Similar to fish shell or pgcli's suggestion style #### 4. Syntax Highlighting - Keywords, strings, numbers, comments in distinct colors - Configurable theme (at minimum: light/dark presets) --- ### Implementation Reference `pgcli`, `mycli`, and `litecli` (all under the **dbcli** org) solve this with Python's `prompt_toolkit`. For a Go-based approach, the following libraries are worth evaluating: | Library | Notes | |---|---| | [`charmbracelet/bubbletea`](https://github.com/charmbracelet/bubbletea) | Full TUI framework, active Go ecosystem | | [`chzyer/readline`](https://github.com/chzyer/readline) | Drop-in readline with completion support | | [`c-bata/go-prompt`](https://github.com/c-bata/go-prompt) | Closest Go equivalent to `prompt_toolkit` — has live suggestions, history, colors | `go-prompt` in particular is very close to what's needed here — it supports dynamic completions (schema-aware is possible by querying `information_schema` on connect) and inline hints. --- ### Scope / Phasing Suggestion If a full implementation is too large for one PR, a minimal useful subset would be: 1. **Phase 1** — SQL keyword completion via `Tab` (no schema awareness) 2. **Phase 2** — Schema-aware table/column completion on connect 3. **Phase 3** — Inline ghost-text hints + syntax highlighting --- ### Who Would Benefit Users who: - Work with **multiple databases daily** and can't use pgcli/mycli exclusively - Use `usql` as their sole DB CLI and want a modern REPL experience - Script with `usql` but also use it interactively --- *Appreciate the work on `usql` — it's the only tool that handles this many databases cleanly. Autocompletion would make it genuinely complete.*
关闭于 2026-03-14 4 条评论