Skip to content

feat(lsp): inlayHints.parameterNames to show parameter names for constants only - #948

Open
psteinroe wants to merge 1 commit into
perf/editor-requests-off-runtimefrom
feat/inlay-hint-parameter-names
Open

psteinroe wants to merge 1 commit into
perf/editor-requests-off-runtimefrom
feat/inlay-hint-parameter-names

Conversation

@psteinroe

Copy link
Copy Markdown
Collaborator

Stacked on #931.

Inlay hints could only be on or off. On calls whose arguments are column references or expressions, the parameter names mostly repeat what the code already says; on constants they're the useful part.

{ "inlayHints": { "parameterNames": "literals" } }
select make_point(1, -2), make_point(a + 1, b), greet('bob', null) from points;
-- "all" (default): make_point(x: 1, y: -2), make_point(x: a + 1, y: b), greet(name: 'bob', greeting: null)
-- "literals":      make_point(x: 1, y: -2), make_point(a + 1, b),       greet(name: 'bob', greeting: null)
-- "none":          no hints

I kept it to the three values TypeScript has (includeInlayParameterNameHints: "none" | "literals" | "all"). rust-analyzer only has an on/off switch, and an argument named like its parameter already gets no hint here, like TypeScript's ...WhenArgumentMatchesName default.

What changed

  • inlayHints.parameterNames (all, literals, none) in the configuration, with schema, TS types and the editor features docs regenerated or updated.
  • pgls_inlay_hints::ParameterNameHints, passed to inlay_hints_of_references and InlayHintsParams. A literal is one token that is a string, number, bit string, boolean or NULL, or a sign and a number. Casts like '1'::int and typed literals like date '...' don't count.
  • pull_inlay_hints returns nothing for none, like for enabled: false.

Tests

Configuration deserialization (and rejecting unknown values), the crate's hints with literals, and a workspace test for all three values.

…tants only

Like TypeScript's includeInlayParameterNameHints: "all" (the default),
"literals" for constant arguments only, or "none".

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant