pherrymason / c3-lsp

Language Server for C3 Language
https://pherrymason.github.io/c3-lsp/
GNU General Public License v3.0
75 stars 10 forks source link

Add Size and Alignment on type/field hover #70

Open Caleb-o opened 2 months ago

Caleb-o commented 2 months ago

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like Both Golang and Rust show the size and alignment of types. Since C3 is a lower level language, it would be useful to have this information available on hover, instead of needing to use something like reflection.

Describe alternatives you've considered Reflection could be used, but it is not as convenient

Additional context Type: image

Field (from Josh): image

joshring commented 2 months ago

Go's LSP Gopls may be a helpful reference, here's the code: https://go-review.googlesource.com/c/tools/+/573076

pherrymason commented 2 months ago

Is there any reference on C3 about what size every type uses?

Caleb-o commented 2 months ago

There is a list on basic types that shows the bit size of primitives

Caleb-o commented 2 months ago

As a note, you also need to take alignment into account for padding in structs. Unions are just the size of their largest item. To verify that types are calculated properly, you can use sizeof from type properties to validate the size is correct.

Caleb-o commented 1 month ago

@pherrymason how is this going? There was some progress posted in the tooling channel of discord, but haven't heard anything since. Did you get stuck or did life start doing life things and you've been busy?

pherrymason commented 1 month ago

Sorry, I've been more busy lately and could not advance with this