Skip to content

Conversation

@roife
Copy link

@roife roife commented Dec 9, 2025

Skip parameter name inlay hints when the argument name matches the parameter to avoid redundant labels.

DEMO

Before omitting:

image

After omitting:

image

Copilot AI review requested due to automatic review settings December 9, 2025 06:44
@gemini-code-assist
Copy link

Summary of Changes

Hello @roife, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the user experience of inlay hints by intelligently suppressing parameter name hints when they are redundant. By comparing the argument's name with the parameter's name, the system avoids displaying unnecessary labels, leading to a cleaner and more focused code view. This change is accompanied by a new, thorough test file to validate the behavior of various inlay hint types.

Highlights

  • Parameter Hint Omission: Implemented logic to automatically omit parameter inlay hints when the argument name passed to a function matches the parameter's name, reducing visual redundancy.
  • New Inlay Hint Tests: Added a dedicated test suite for inlay hints, covering type hints, parameter name hints (including the new omission behavior), and array index hints.
  • Test Suite Integration: Updated the main test runner to include the newly added inlay hint tests, ensuring comprehensive coverage.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new test cases for inlay hints, specifically covering type hints, parameter name hints, and array index hints. A change was made to the paramName function in script/core/hint.lua to prevent parameter name hints from appearing when an argument's name is identical to the parameter's name. The reviewer acknowledges the new tests but suggests adding a further test case for paramName set to 'All' to ensure that hints are correctly displayed when a string literal's value matches a parameter name, as the current implementation might incorrectly omit such hints.

local first, second
foo(<!first!>, <!second!>)
]], {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's great that you've added tests for the new functionality! To make the tests more comprehensive, consider adding a test case for when a string literal's value matches a parameter name. The current implementation might incorrectly omit the hint in this scenario, and this test would help verify the correct behavior.

For example, with paramName set to 'All', a call like foo('s') to a function function foo(s) end should still display the s: hint.


config.set(nil, 'Lua.hint.paramName', 'All')

TEST([[
local function foo(s)
end

foo(<!'s'!>)
]], {
    {
        pos   = 1,
        text  = 's:',
        kind  = define.InlayHintKind.Parameter,
        where = 'left',
    },
})

@roife roife force-pushed the omit-param-inlay-hint branch from e7727d9 to ca31f4f Compare December 9, 2025 06:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the inlay hint feature by omitting parameter name hints when the argument name matches the parameter name, reducing visual clutter in the code editor. The change applies to the Lua Language Server's hint system when using the 'All' parameter hint mode.

Key Changes

  • Modified parameter hint logic to skip hints when argument variable names match parameter names
  • Added comprehensive test suite for the inlay hint feature
  • Integrated the new test file into the test runner

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
script/core/hint.lua Added condition param[1] ~= arg[1] to skip hints when argument name matches parameter name
test/inlay_hint/init.lua New test file with comprehensive coverage for inlay hints including type hints, parameter hints, and array index hints
test.lua Added 'inlay_hint' to the test suite execution list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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