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

LSP Type Hints #2070

Closed
oati opened this issue Apr 11, 2022 · 11 comments · Fixed by #5934 or #6320
Closed

LSP Type Hints #2070

oati opened this issue Apr 11, 2022 · 11 comments · Fixed by #5934 or #6320
Labels
A-helix-term Area: Helix term improvements A-language-server Area: Language server client C-enhancement Category: Improvements

Comments

@oati
Copy link
Contributor

oati commented Apr 11, 2022

I'm not sure how straightforward this would be to implement.
Type hints could be given on hover, or overlaid on the text like this: rust-lang/vscode-rust#374

image

@oati oati added the C-enhancement Category: Improvements label Apr 11, 2022
@oati oati changed the title Type Hints LSP Type Hints Apr 11, 2022
@kirawi
Copy link
Member

kirawi commented Apr 11, 2022

(ignore)

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Apr 11, 2022
@kirawi
Copy link
Member

kirawi commented Apr 11, 2022

I don't think the LSP protocol defines this, so it would probably have to be implemented by a plugin.

Edit; Never mind, seems to have been recently added.

@kirawi kirawi marked this as a duplicate of #411 Apr 11, 2022
@kirawi kirawi added R-duplicate Duplicated issue: please refer to the linked issue A-helix-term Area: Helix term improvements and removed A-helix-term Area: Helix term improvements R-duplicate Duplicated issue: please refer to the linked issue labels Apr 11, 2022
@kirawi kirawi marked this as not a duplicate of #411 Apr 11, 2022
@kirawi kirawi added the A-language-server Area: Language server client label Apr 11, 2022
@rehtlaw
Copy link

rehtlaw commented Oct 11, 2022

What's the current status on this? Is #417 the PR to look out for?

@David-Else
Copy link
Contributor

TypeScript 4.4 just added inlay hints: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-4.html#inlay-hints

Deno 1.27 added inlay hints: https://deno.com/blog/v1.27#language-serveride-improvements

Would be fantastic to get virtual text up and running and get inlay hints available!

@pascalkuthe
Copy link
Member

This feature is blocked om two PRs:

@112RG
Copy link

112RG commented Jan 29, 2023

Excited for this

@poliorcetics
Copy link
Contributor

With both blocking MR being merged and an lsp-types release done, it should be possible to do it now!

Is there someone already working on it so we can help or is it available for pickup ?

@pascalkuthe
Copy link
Member

Somebody posted a screenshot of a prototype on the matrix channel. He said he may do a PR but never heard back from him. So I am guessing nobody is currently working on it. This feature should be pretty easy to implement now.

@poliorcetics
Copy link
Contributor

There is now #5934, I recommand testing it on your side since I only really tested with Rust-Analyzer and other LSPs may have different behaviours

@erasin
Copy link
Contributor

erasin commented Feb 16, 2023

@poliorcetics

I tested with go, typescript, and Lua, It's very cool to me.

If anyone needs to config to LSP.

# language.toml config for inlay hit


[[language]]
name = "go"

[language.config.hints]
assignVariableTypes = true
compositeLiteralFields = true
constantValues = true
functionTypeParameters = true
parameterNames = true
rangeVariableTypes = true

[[language]]
name = "lua"

[language.config.Lua.hint]
enable = true
arrayIndex = "Enable"
setType = true
paramName = "All"
paramType = true
await = true


[[language]]
name = "typescript"

[language.config]
hostInfo = "helix"

[language.config.typescript.inlayHints]
includeInlayEnumMemberValueHints = true
includeInlayFunctionLikeReturnTypeHints = true
includeInlayFunctionParameterTypeHints = true
includeInlayParameterNameHints = "all"                       # 'none' | 'literals' | 'all';
includeInlayParameterNameHintsWhenArgumentMatchesName = true
includeInlayPropertyDeclarationTypeHints = true
includeInlayVariableTypeHints = true

[[language]]
name = "tsx"

[language.config]
hostInfo = "helix"

[language.config.typescript.inlayHints]
includeInlayEnumMemberValueHints = true
includeInlayFunctionLikeReturnTypeHints = true
includeInlayFunctionParameterTypeHints = true
includeInlayParameterNameHints = "all"                       # 'none' | 'literals' | 'all';
includeInlayParameterNameHintsWhenArgumentMatchesName = true
includeInlayPropertyDeclarationTypeHints = true
includeInlayVariableTypeHints = true

[[language]]
name = "javascript"

[language.config]
hostInfo = "helix"

[language.config.javascript.inlayHints]
includeInlayEnumMemberValueHints = true
includeInlayFunctionLikeReturnTypeHints = true
includeInlayFunctionParameterTypeHints = true
includeInlayParameterNameHints = "all"                       # 'none' | 'literals' | 'all';
includeInlayParameterNameHintsWhenArgumentMatchesName = true
includeInlayPropertyDeclarationTypeHints = true
includeInlayVariableTypeHints = true

[[language]]
name = "jsx"

[language.config]
hostInfo = "helix"
locale = "zh-CN" 

[language.config.javascript.inlayHints]
includeInlayEnumMemberValueHints = true
includeInlayFunctionLikeReturnTypeHints = true
includeInlayFunctionParameterTypeHints = true
includeInlayParameterNameHints = "all"                       # 'none' | 'literals' | 'all';
includeInlayParameterNameHintsWhenArgumentMatchesName = true
includeInlayPropertyDeclarationTypeHints = true
includeInlayVariableTypeHints = true


ref:

@poliorcetics
Copy link
Contributor

I tested with go, typescript, and Lua

Nice, glad to know it worked with all of them, thanks for testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements A-language-server Area: Language server client C-enhancement Category: Improvements
Projects
None yet
8 participants