helix icon indicating copy to clipboard operation
helix copied to clipboard

LSP Type Hints

Open oati opened this issue 2 years ago • 4 comments

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

image

oati avatar Apr 11 '22 01:04 oati

(ignore)

kirawi avatar Apr 11 '22 02:04 kirawi

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 avatar Apr 11 '22 02:04 kirawi

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

rehtlaw avatar Oct 11 '22 13:10 rehtlaw

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!

David-Else avatar Oct 28 '22 10:10 David-Else

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

pascalkuthe avatar Jan 28 '23 10:01 pascalkuthe

Excited for this

112RG avatar Jan 29 '23 17:01 112RG

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 ?

poliorcetics avatar Feb 10 '23 13:02 poliorcetics

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.

pascalkuthe avatar Feb 10 '23 13:02 pascalkuthe

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 avatar Feb 12 '23 03:02 poliorcetics

@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:

erasin avatar Feb 16 '23 14:02 erasin

I tested with go, typescript, and Lua

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

poliorcetics avatar Feb 16 '23 14:02 poliorcetics