Skip to content
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

(feat) TypeScript Inlay Hint #1855

Merged
merged 8 commits into from Feb 7, 2023
Merged

Conversation

jasonlyu123
Copy link
Member

@jasonlyu123 jasonlyu123 commented Feb 4, 2023

#1336

This is not enabled by default. You'll have to enable it with the TypeScript inlay hints configs of VSCode. There are multiple configs under javascript.inlayHints.* and typescript.inlayHints.*. Enable them based on your preference.

implementation detail

The test is set up similarly to the diagnostics snapshot test. You can also run yarn test --debug to output debug.svelte with inlay hints added to the original file as comments. for example:

<script lang="ts">
    import { SvelteComponentTyped } from 'svelte';

    let Component: typeof SvelteComponentTyped;
    function hi(name: string)/* : void*/ {}
</script>

<Component text={hi(/*name: */'')}></Component>

Screenshots

圖片
圖片

(enable all inlay hints options is really just too much for my taste lol)

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

Damn, this is impressive work - thank you so much!

@dummdidumm dummdidumm merged commit 0c8ca1e into sveltejs:master Feb 7, 2023
@brunnerh
Copy link
Member

Nice!

(enable all inlay hints options is really just too much for my taste lol)

I've found that the default style is just way too aggressive (though I also disabled a few).

Toned them down to look like this:
image

// Settings for that:
{
	"workbench.colorCustomizations": {
		"[Default Dark+][Default Dark+ Experimental]": {
			// ...
			"editorInlayHint.background": "#00000000",
			"editorInlayHint.foreground": "#ffffff69",
		},
	},
}

@polyzen
Copy link

polyzen commented Feb 23, 2023

Is this also available via svelte.plugin.typescript.inlayHints.enable? Not listed in the readme. Would like to use this in Neovim.

@dummdidumm
Copy link
Member

This uses the VSCode TypeScript options to enable it. How does Neovim enable it for TS (through which option(s))?

@polyzen
Copy link

polyzen commented Feb 23, 2023

This uses the VSCode TypeScript options to enable it. How does Neovim enable it for TS (through which option(s))?

https://github.com/lvimuser/lsp-inlayhints.nvim#typescript

@aidenlangley
Copy link

aidenlangley commented Feb 24, 2023

#1895

Neovim doesn't handle any of the workspace/something/refresh. requests right now. Need this to be configurable really, for now anyway.

https://github.com/typescript-language-server/typescript-language-server

The tsserver README also states:

textDocument/inlayHint (no support for inlayHint/resolve or workspace/inlayHint/refresh)

@dummdidumm
Copy link
Member

@polyzen you can read about the settings here: https://github.com/sveltejs/language-tools/tree/master/packages/language-server#settings , settings references are linked

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.

None yet

5 participants