JohnnyMorganz / luau-lsp

Language Server Implementation for Luau
MIT License
198 stars 48 forks source link

Add option to display Luau compiler remarks alongside code #514

Closed grilme99 closed 6 months ago

grilme99 commented 6 months ago

There are a few fringe use cases when debugging performance where looking at the compiler's remarks output would be helpful. The default way to do this, luau-compile --remarks, slows down iteration. What would be better is if Luau LSP could display these remarks alongside my code, such as in a code lens.

Internal Roblox engineers have a workflow like this inside of Roblox Studio:

image Taken from the OSS discord, code is from a hack week project

LastTalon commented 6 months ago

Should they be a code lens or should they be infos? They seem like they're more likely infos to me and I have those displayed inline alongside warnings and errors using the error lens extension.

JohnnyMorganz commented 6 months ago

I wanted to do something like how the error lens extension works. But it turns out it's a non-standard VSCode thing and they rolled their own ui patches to make inline diagnostics show up at EOL. Sad :(

Infos seem like an interesting choice, but it is messy (in terms of LSP work) to mix this stuff with diagnostics. Also, this assumes that everyone using this also uses error lens, unsure how it will look generally.

Anyways, best way to decide how to display this is to just try it and see. Will see how it looks

JohnnyMorganz commented 6 months ago

Another option we have here is opening a readonly document with remarks as comments in the source file when the command is run. @grilme99 do you think that would be suitable? Or would you rather the data is inlined somewhere in the current source file

JohnnyMorganz commented 6 months ago

Added the viewer. In the end I decided to do a separate panel, which auto updates as you type / switch files.

I also went ahead and did textual bytecode output too

https://github.com/JohnnyMorganz/luau-lsp/assets/19635171/6d5ea652-7f5f-47fc-acf0-9c823a9de0a0

Added in https://github.com/JohnnyMorganz/luau-lsp/commit/77e7690b2bff7bee622803a731e1f840823a3214 and https://github.com/JohnnyMorganz/luau-lsp/commit/fb4d15eb99bae730001abd263f74e3d08234c645

LastTalon commented 6 months ago

Also, this assumes that everyone using this also uses error lens, unsure how it will look generally.

I think infos (or at least an option to make them infos) would be good even if people aren't using error lens. It's something that you can view regardless of that extension, error lens just makes it very readily apparent. I can understand that mixing it with the other diagnostics can be a problem though.