-
Notifications
You must be signed in to change notification settings - Fork 253
Added limited support for type showing code lenses #1442
Conversation
For now, it only shows types for variables that are being declared alone with a `let (mut) var`, and refreshes slightly too early (you need to type a bit to wake it up after just writing a new declaration. It also does no typename compacting, so the fact that I haven't made the lenses inline is a plus for now.
|
Travis CI says it doesn't compile, maybe its version of rustc is lower than the 1.36 I'm using ? |
|
Hi! Sorry for the delayed response; this looks awesome! |
|
Hi, I don't mind waiting a bit, I wasn't expecting this to be merged as is anyway. My main concern is the update timing of the lenses though: as of today, lenses are refreshed on save and on editor change. Due to this, indexing is not finished by the time lenses are asked, so you have to do something manually after finishing your edit to a declaration statement in order to refresh the lenses. Finally, if you know how to get my lenses nicely inlined with their declaration, I could start trying to place them inside other patterns too (closures, pattern matching...) Hopefully we can get this feature up and running soon, it's the only thing I really miss from CLion (well, this and match arms completion in the code fixes) See you. |
|
☔ The latest upstream changes (presumably #1448) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Just a little a parte on typename shortening: although I agree we should leave this to rustc, my lack of knowledge of it made implementing this more efficient as a PoC. The implementation I give there is just a way to get the imports and named imports from the current file and use them in the lenses, so that when I do find a way to display them inline, we don't all suddenly need 21/9 monitors 😃 I've seen cases where |
|
After eating some Swiss chocolate, I think I found why my lenses won't go inline: they simply can't, GitLens uses decorations for the inline stuff. |
|
Ok, since I can't inline them yet (see previous comment), I've gone with plan B: the lenses now show the name of the variable they give a type for. Anyway, some cleanup is probably necessary, and that many lenses with the same old refresh not happening at end of indexing issue is probably too intrusive to not be optional, but I'm gonna start using it as is. Note that I had to add a |
clippy revision dependency has caused me many headaches with rustc versions, hopefully this makes it a bit less painful
Lens range moved to end of work for tuple and parameter unpacking as prelude to Decoration based type hints that I plan for the VSCode client
|
STOP |

Hello There!
I wanted to have Lenses to show the types of variables in the editor much like CLion does in VSCode. Here is my first go at it.
I'm pretty sure it won't be merged as is, but input on how to get it up to your standards (and maybe some pointers on how to actually code it) are welcome.
For now, it only shows types for variables that are being declared alone with a
let (mut) var, and refreshes slightly too early (you need to type a bit to wake it up after just writing a new declaration).It also does no typename compacting, so the fact that I haven't made the lenses inline is a plus for now in my opinion, but it's a little invasive, so it should probably become optional if it is to stay that way.
Here's a little example of how it looks.

I had to update clippy-lints to get it to compile, in case you wonder why I changed the ref in Cargo.toml.
Have a nice day :)