Skip to content

Feature: Autocomplete / IntelliSense for SQL editing #11

@muk2

Description

@muk2

Overview

Add schema-aware autocomplete to the SQL editor, providing suggestions for table names, column names, SQL keywords, and functions as the user types.

Goals

  • Fast, responsive autocomplete popup triggered by typing
  • Schema-aware: suggest real table/column names from the connected database
  • Keyword/function completion for SQL syntax
  • Contextual suggestions (e.g., after FROM suggest tables, after SELECT suggest columns)

Proposed Behavior

Trigger

  • Autocomplete popup appears automatically after typing 2+ characters
  • Can also be manually triggered with Ctrl+Space
  • Dismiss with Esc

Suggestion Sources (priority order)

  1. Table names — from loaded schema (qualified: schema.table)
  2. Column names — from tables already referenced in the query
  3. SQL keywordsSELECT, FROM, WHERE, JOIN, etc.
  4. SQL functionsCOUNT(), JSONB_BUILD_OBJECT(), etc.
  5. SQL typesINTEGER, TIMESTAMPTZ, JSONB, etc.

Navigation

  • Up/Down — navigate suggestions
  • Tab or Enter — accept suggestion
  • Esc — dismiss popup
  • Continue typing to filter suggestions

Context Awareness

After typing... Suggest...
FROM Table names
JOIN Table names
SELECT t. Columns of table aliased as t
WHERE Column names from referenced tables
:: Type names
Any partial word Keywords, functions, tables matching prefix

Implementation Suggestions

  • Add AutocompleteState struct to App (active, suggestions list, selected index, filter text)
  • Build suggestion list from app.tables, app.schemas, SQL_KEYWORDS, SQL_FUNCTIONS, SQL_TYPES
  • Render as a floating popup widget below the cursor position
  • Use case-insensitive prefix matching for filtering
  • Cache column lists per table to avoid repeated DB queries

UI Mockup

SELECT u.|
         ┌──────────────────┐
         │ id          INT4 │
         │ name        TEXT │
         │ email       TEXT │
         │ created_at  TSTZ │
         └──────────────────┘

Definition of Done

  • Autocomplete popup renders correctly below cursor
  • Table and column names from schema appear as suggestions
  • SQL keywords and functions appear as suggestions
  • Typing filters the list in real-time
  • Tab/Enter inserts the selected suggestion
  • Esc dismisses the popup
  • No noticeable input lag when popup is active

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions