Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add an extension setting to control inlay hints #1526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add an extension setting to control inlay hints #1526
Changes from all commits
a2f1d29
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to automatically add a .vscode/settings.json file for every package opened in VS Code and add the following to it:
When I update .vscode/settings.json to set this value to
"on"
, save, and reload the window it gets re-written to"off"
.Automatically resetting the setting aside, I don't think we should be generating a settings.json for the user at all as these are meant to be for the user to control, not an extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yes agreed that touching settings.json automatically is probably not welcome (although we do touch the settings.json for other things like swift environment variables, for example, but the user would have to set them manually I think). Any other suggestions on how the inlay hints could be disabled by default so that new users who don't know how to turn this setting off are not annoyed?
Could send a setting to sourcekit-lsp separately to turn off inlay hints possibly, and then if the user says:
or sets
swift.inlayHints.enabled
totrue
then it would turn on inlay hints?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do other extensions handle this? Do popular language extensions they swim against the VS Code defaults?
My gut feeling is we should tell sourcekit-lsp to disable them unless there is a setting set explicitly that turns them on, but because the default for editor.inlayHints.enabled is "on" I dont know if we can tell if this is explicitly set by the user or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good ideas thanks, it seems like most do it with passing in flags to lsp (Go does it with gopls and rust with rust-analyser), although it looks like C/C++ use vscode api's to override inlayHint behaviour directly.
You are correct that it's not possible to tell whether
editor.inlayHints.enabled
is explicitly set toon
. So it's looking like I'll just have to add functionality like thesourcekit-lsp.inlayHints.enabled
setting had at one point.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the
inspect()
method to find out if the user has explicitly configured a setting. Have a look at https://github.com/swiftlang/vscode-swift/blob/main/src/configuration.ts#L245 for an example in the Swift extension's configuration. It will even tell you if it has been configured for a particular language.