Closed nbransby closed 2 years ago
I just switched to VS Code and was missing this feature for PHP files, so I implemented it myself. Still in beta, but workable: https://marketplace.visualstudio.com/items?itemName=BobbyZrncev.intellij-parameter-hints
Thanks to @lannonbr for inspiration.
This feature would be extremely useful!
For inspiration rust-analyzer is doing this in vscode today.
This feature would be great! Meanwhile, I'm using JS Parameter Annotations
This would be a really great feature. Please, hear us out. 🚀
It has been 3 years!!!
This is very helpful and give us a large productivity scale.
We hear you... but these +1 comments are not productive. Locking to prevent more noise
Try https://marketplace.visualstudio.com/items?itemName=lannonbr.vscode-js-annotations in the meantime
lannonbr's extension is deprecated.
There is this one available now: https://marketplace.visualstudio.com/items?itemName=liamhammett.inline-parameters
I'm using this one, pretty good too:
Name: Parameter Hints Id: dominicvonk.parameter-hints Description: Automatic parameter hints Version: 0.2.7 Publisher: Dominic Vonk VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=DominicVonk.parameter-hints
I'm using this one, pretty good too:
Name: Parameter Hints Id: dominicvonk.parameter-hints Description: Automatic parameter hints Version: 0.2.7 Publisher: Dominic Vonk VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=DominicVonk.parameter-hints
wow, is the first one where i add and work the first time without config ! thanks for share ! look very clean for me and my theme, seem no bug !
Parameter name hints are now supported with TypeScript 4.4:
TypeScript 4.4 will be picked up in the August VS Code release. To test this feature in the current VS Code insiders build:
"typescript.inlayHints.parameterNames.enabled": "all"
or "javascript.inlayHints.parameterNames.enabled": "all"
❗ Please give this feature a try and open new issues for any problems / feature requests related to it ❗
But wait, there's more!!!
In addition to parameter names, you can also turn on hints for:
typescript.inlayHints.variableTypes.enabled
typescript.inlayHints.propertyDeclarationTypes.enabled
typescript.inlayHints.functionLikeReturnTypes.enabled
typescript.inlayHints.parameterTypes.enabled
typescript.inlayHints.enumMemberValues.enabled
These are all disabled by default in both JS and TS. Here's a look at a JS file showing some of those additional hints enabled:
There are also two configurations you can use to control when parameter name hints are shown:
With "typescript.inlayHints.parameterNames.suppressWhenArgumentMatchesName": true
, hints are not shown if the passed in argument matches the parameter name:
function foo(abc: number) { }
const abc = 123;
foo(abc) // no hint here since abc === abc
With "typescript.inlayHints.parameterNames.enabled": "literals"
, parameter name hints are only shown on literal types (string, number, function, object, ...)
Parameter name hints are now supported with TypeScript 4.4
Out of curiosity, how does this work at the LSP layer? My understanding is the LSP protocol support hasn't been merged yet. Or does Typescript not use LSP?
@mjbvz Can you link to how the inlay hints is implemented in the LSP for typescript? I'd like to do implement this for another language, thank you/
Or does Typescript not use LSP?
Correct, because TypeScript language server was created before the invention of LSP, it doesn't use LSP. TypeScript team doesn't want to switch to LSP because it will either break old clients or require maintaining two protocols.
In fact, Code also doesn't have built-in support for LSP. Code team has an official npm package to bridge between LSP features and Code extension APIs, that extension authors must install it themselves to make LSP servers work with Code.
Or does Typescript not use LSP?
Correct, because TypeScript language server was created before the invention of LSP, it doesn't use LSP. TypeScript team doesn't want to switch to LSP because it will either break old clients or require maintaining two protocols.
In fact, Code also doesn't have built-in support for LSP. Code team has an official npm package to bridge between LSP features and Code extension APIs, that extension authors must install it themselves to make LSP servers work with Code.
Full LSP support is part of Typescripts official roadmap: https://github.com/microsoft/TypeScript/issues/39459
How can I customize the inlay tokens with editor.tokenColorCusomizations
? what scope is it?
Keeping this open to finalize the API
How can I customize the inlay tokens with
editor.tokenColorCusomizations
? what scope is it?
@sschneider-ihre-pvs You cannot do this via editor.tokenColorCustomizations
, but via workbench.colorCustomizations
:
...
"workbench.colorCustomizations": {
"[My Theme]": {
"editorInlayHint.foreground": "#FF0000",
"editorInlayHint.background": "#FFFF00",
}
},
...
As documented here: https://code.visualstudio.com/api/references/theme-color
I meant the inlay token font-style.
I meant the inlay token font-style.
Look at the editor.inlayHints.fontFamily
setting.
I did that already but I can't pick an italic style that is the reason I was asking for font-style.
Can we have support for inline parameters hint for others languages like Java ?
Can we have support for inline parameters hint for others languages like Java ?
The API is not language-specific. The language extension authors will need to implement it when the API is finalized.
EDIT: See redhat-developer/vscode-java#2099 for the Java issue
When will this feature be available for python?
Should be closed by #42089?
See this StackOverflow question it is related to this issue if you know the answer then please tell
How to activate it in .vue
components?
Is there a way to activate this for the C/C++
codebases?
The API has been finalised, the feature is implemented. All further work is tracked with the inlay-hints
-label
To verify ensure that registerInlayHintsProvider is in latest vscode.d.ts
Would be useful for typescript: https://youtu.be/ZfYOddEmaRw