Feat: LS show const values on hover #5516
Replies: 7 comments
-
|
I believe in typescript, the type is const a = 10
const b = a
// ^ hover hereWhat would we show in this case? |
Beta Was this translation helpful? Give feedback.
-
That's a good question. I think just showing the value is already a nice DX that avoids a jump to definition but if it would be cool to, as you say, reduce down to the actual value. e.g. const base_url = "https://zanca.dev"
const page_url = base_url <> "/gear"
// ^ const page_url = "https://zanca.dev/gear"Records too? const name = "Metru"
const default_context = Context(name)
// ^ const default_context = Context( username: "Metru" )If users want to see what its composed from, they can jump to definition. I think its more useful in both these scenarios to be able to quickly see the result. |
Beta Was this translation helpful? Give feedback.
-
|
Showing computed values when the definition is an expression would require compile time compilation, which we don't have. Let's defer this until a second iteration of this feature. Constants can be arbitrarily large. Do we need to truncate or trim them in any way? |
Beta Was this translation helpful? Give feedback.
-
|
Hello! So any ideas on what the design of this would be? I'm not really sure about truncating, are there any other language servers that do this we could take inspiration from? In Rust it shows the entire constant declaration if the constant is not too long, but hides the value of the constant after the |
Beta Was this translation helpful? Give feedback.
-
|
Is it too long as some number of lines? |
Beta Was this translation helpful? Give feedback.
-
|
Ah I got it wrong, it never shows the actual value unless it's a numeric value. For anything like structs, tuples, strings, and slices it always adds the value and only shows the head like this: Quite odd, I don't think there's any value in showing that since hover already shows the type and the name is right under the cursor |
Beta Was this translation helpful? Give feedback.
-
|
I'm gunna convert this to a discussion as we've not worked out a good way approach yet |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Say you have this setup:
Coming from writing typescript all day, I was expecting to see the value for constants.
It would be nice if, like typescript, it showed a message like
const redirect: Int = 303. (using valid syntax in this popup to avoid confusion)Beta Was this translation helpful? Give feedback.
All reactions