Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion: show type spec for struct fields #751

Merged
merged 1 commit into from
May 23, 2024

Conversation

kirillrogovoy
Copy link
Contributor

Fixes #749

:type_spec is already a part of the elixir_sense_map, so defining it in defstruct is enough.

If the struct doesn't have a type spec, it would show "Field" in my editor probably because that's how it handles completion.detail == nil

Let me know if it's more desirable to fall back to some string explicitly, e.g.:

builder.plain_text(env, struct_field.name,
  detail: struct_field.type_spec || "Field",
  label: struct_field.name,
  kind: :field
)

@scohen
Copy link
Collaborator

scohen commented May 23, 2024

I think "Field" is coming from the LSP "kind" of the completion, and detail is nil-able, which means it'll just not display anything. It might be interesting to display "dynamic" or "unknown type" there, but that might just be noisy.

FYI, my editor (emacs) also displays "Field" on completions.

This looks great. Thanks for contributing!

@scohen scohen merged commit b6a6a47 into lexical-lsp:main May 23, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Struct autocomplete: Show the type
2 participants