Skip to content

feat(lsp): refresh and settings for inlay hints and semantic tokens - #911

Open
psteinroe wants to merge 1 commit into
feat/semantic-tokensfrom
feat/editor-features-refresh-settings
Open

psteinroe wants to merge 1 commit into
feat/semantic-tokensfrom
feat/editor-features-refresh-settings

Conversation

@psteinroe

@psteinroe psteinroe commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #888.

Inlay hints and semantic tokens stayed stale until the next edit whenever they changed for another reason, and there was no way to turn them off on the server side.

What was broken

  • After pgls.invalidateSchemaCache, a configuration change, or a database that came up after the first request returned nothing, hints and tokens kept showing the old state (or nothing) until the user typed. Diagnostics are refreshed at these points, hints and tokens weren't: there was no workspace/inlayHint/refresh or workspace/semanticTokens/refresh anywhere.
  • Both capabilities are always advertised and there were no settings, so Neovim, Helix or Zed users whose theme colours get overridden by semantic tokens had to find an editor-side switch.

What changed

  • Session::refresh_editor_features sends both refresh requests, each only if the client declares refreshSupport, without waiting for the answer. It runs:
    • at the end of update_all_diagnostics, which covers initialized, workspace/didChangeConfiguration, pgls/set_configuration_overrides and pgls.executeStatement;
    • after pgls.invalidateSchemaCache, which now also refreshes diagnostics (they depend on the schema too and didn't refresh before);
    • after a reload triggered by a change of the configuration file;
    • when the database becomes reachable: if an inlay hint or semantic token request failed with a connection error, the next diagnostics run checks the connection with check_database_connection and refreshes once it works.
  • New configuration sections, through the normal config, schema and TS codegen:
{
  "inlayHints": { "enabled": false },
  "semanticTokens": { "enabled": false }
}

Both default to true. When disabled, the workspace returns no hints/tokens, so the editor keeps its grammar highlighting. The capabilities are still advertised; switching at runtime then only needs the refresh.

  • docs/features/editor_features.md is rewritten ("Editor Features"): hover through the file's DDL, SQL function bodies and CTE/subquery columns, inlay hints, semantic tokens with the token table and enum rules, how to turn them off, and a limitations list (unique references only, DO/CALL/unparsable statements, CALL, BEGIN ATOMIC and '' bodies, missing token kinds, large files). The follow-up PRs that lift some of these limitations update the list.

Tests

LSP test test_editor_features_refresh_and_settings: a client with refresh support gets both refresh requests after the configuration is loaded, after pgls.invalidateSchemaCache, and after a didChangeConfiguration that disables both features, after which hints and tokens are empty. The test client now answers refresh requests and forwards them as notifications.

Not covered

  • The "database became reachable" path has no automated test: the test database is always up, so it would need a server that starts unreachable.
  • No parameter-name mode for inlay hints (e.g. only for literals) yet, just on/off.

Follow-ups: The parameter-name mode is added in #948.

Ask the client to request inlay hints and semantic tokens again when the
configuration changes, the schema cache is invalidated, a statement is
executed, or the database becomes reachable after they were requested
without it. Add inlayHints.enabled and semanticTokens.enabled, and rewrite
the editor features docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant