lexical-lsp / lexical

Lexical is a next-generation elixir language server
776 stars 77 forks source link

Struct autocomplete: Show the type #749

Closed kirillrogovoy closed 1 month ago

kirillrogovoy commented 1 month ago

Hey,

Lexical is fantastic! ❤️

Sorry if this issue has already been mentioned. Could not find anything in the issues.

When ElixirLS completes access to a struct field, it shows some type information (given that the struct has a spec):

Screenshot 2024-05-22 at 16 52 10

However, Lexical doesn't (the examples are from Neovim and VS Code respectively):

Screenshot 2024-05-22 at 16 49 55 Screenshot 2024-05-22 at 16 48 31

Is there an easy way to fix that? 🤔 I have very little experience in LSP but happy to jump in with some guidance.

scohen commented 1 month ago

this might be signature help, which we do have an open issue for (#349) I'm not sure if this is an easy PR, but if you want to contribute, we'll be more than happy to support you!

scohen commented 1 month ago

I'll add that the types you've shown seem to do little other than add noise though. That's a lot of text to tell you that it's a struct field of type Payload{}. From a product perspective, we'll have to figure this out.

kirillrogovoy commented 1 month ago

Yeah, the part you are referring to is noise.

I was referring to the type spec info specifically.

I've actually just done it locally!! (this is Lexical)

image

Shipping a PR soon to show what I did.

kirillrogovoy commented 1 month ago

The info is already there in the ElixirSense suggestion (type_spec field), so it's super simple.

scohen commented 1 month ago

are those just the details of the completion entry? If so, this would be extremely simple. We have internal Completion.Candidate structs that hold all of the elixir sense data. If that's the case, it's really just a matter of adding the data from the candidate to the LSP struct's details field.

Look in Lexical.Server.CodeIntelligence.Completion.Translations.StructField

scohen commented 1 month ago

It doesn't look like I've mapped the type_spec field of the elixirsense suggestion to the Candidate.StructField struct, so you'll need to do that as well. That's in here