Repository navigation
Conversation
Add a setting that will allow bypassing registering inlay hints so that we can support turning off inlay hints by default in certain IDEs.
|
Suggestions for other ways to do this welcome. I was told I should explore doing this through capabilities directly, as it would be good to not have to restart the LSP to re-enable inlay hints, but putting up the initial idea here for comments. |
|
Linking to the other discussions since I had to look around for them. |
|
Good idea, thanks for the link to the vscode-swift repo @MahdiBM! |
|
We shouldn’t disable inlay hints in SourceKit-LSP by default. SourceKit-LSP is just reporting that it can provide inlay hints and it’s up to the editor to request them. With this PR, it’s very confusing how to enable inlay hints because you need to enable it both in your editor and in the SourceKit-LSP config file (remember that there are other editors that might have different default settings than VS Code). If anything, we should do something in the VS Code Swift extension to disable inlay hints by default – I’m not voicing an opinion on whether we should or should not do that. |
|
Thanks for your comments and concerns @ahoppen. This PR doesn't disable inlay hints in SourceKit-LSP. It only adds a setting where if you pass in The disabling will be done by the VS Code swift extension but it doesn't seem like there is good way to do this from an extension level without touching user settings (see thread here: swiftlang/vscode-swift#1526). The other LSPs have the options to override the textDocument/inlayHints requests they receive whereas SourceKit-LSP does not. Other LSPs also have more inlay hint abilities as mentioned by Mahdi here swiftlang/vscode-swift#1526 (comment) which we can control individually in the future as well when they are implemented. Suggestions welcome. |
The default behaviour for IDEs such as VS Code is to enable all inlay hints. It is possible to turn off inlay hints for Swift through VS Code through user settings but it may be tricky for new users to figure out how to do this. In order to not confuse new users and avoid annoying experienced users, it would be better to turn off the inlay hints by default. Most VS Code extensions such as Go, Python etc. disable inlay hints (for variable type inference, at least) via the LSP probably to avoid touching user/IDE default settings.
This PR is an initial attempt at a new setting that will allow for inlay hint requests to be ignored if
--enable-inlay-hintsis set tofalseduring SourceKit-LSP startup. The goal is to have Swift VS Code extension to disable inlay hints by default until there is a better way to do this via VS Code without having to edit user settings.