helix
helix copied to clipboard
LSP Type Hints
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: https://github.com/rust-lang/vscode-rust/issues/374
(ignore)
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.
What's the current status on this? Is #417 the PR to look out for?
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!
This feature is blocked om two PRs:
- #5420 to add virtual text to helix
- https://github.com/gluon-lang/lsp-types/pull/255 to implement support for LSP 3.17 which stabilized inlay hints
Excited for this
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 ?
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.
There is now https://github.com/helix-editor/helix/pull/5934, I recommand testing it on your side since I only really tested with Rust-Analyzer and other LSPs may have different behaviours
@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:
I tested with go, typescript, and Lua
Nice, glad to know it worked with all of them, thanks for testing!