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

Add completion detail #106

Merged
merged 4 commits into from
Jan 26, 2025
Merged

Conversation

PgBiel
Copy link
Contributor

@PgBiel PgBiel commented Jan 26, 2025

Draft as I couldn't get it to work with Zed for some reason, right now only VSCode is working. Will investigate.

(EDIT: Turns out this will require a PR to c3-zed to work with Zed. That means it isn't the LSP's fault, so the PR itself should be fine. However, I'll keep it as a draft as I'll need to rebase on #103 later. (Done!))

Basically, this adds type information as well as other information to completions, making them more immediately helpful.

This was inspired by a similar feature in the Gleam language's LSP.

I chose to simply add a "Type" hint for struct, bitstruct and union as I felt like being more specific wouldn't be too helpful, but let me know if you'd prefer to have "Struct", "Bitstruct" and "Union" instead (I'd be ok with that as well, the former just felt a bit cleaner to me, but I don't mind it that much).

I also chose "Enumerator" for enum values, but I'm thinking of writing just "Enum value" as that's clearer. (Changed to "Enum Value")

Also, I chose "Fault Constant" for fault constants and "Struct member 'name'" for anonymous substructs.

In addition, defs display "Type" when they're type aliases, or "Alias for ''" otherwise since we have little to no semantic information (as an exception, I also display "Alias for macro '@macroname'" when we know for sure it's a macro due to @).

Future work

  • Perhaps some way to resolve the definition RHS to display better information would be nice.

Screenshots

shows var type 1
shows var type 2
shows function signature
shows local var type
shows "Type" for struct
shows "Enumerator" for enum value
shows "Enum" for enum type
shows "Struct member 'name'" for substructs

@PgBiel PgBiel force-pushed the completion-detail branch from 2a40ffa to 7fe1de8 Compare January 26, 2025 06:35
@PgBiel PgBiel marked this pull request as ready for review January 26, 2025 06:54
@pherrymason pherrymason merged commit cd12bcc into pherrymason:main Jan 26, 2025
2 checks passed
@pherrymason
Copy link
Owner

Thank you again!

@PgBiel PgBiel deleted the completion-detail branch January 26, 2025 18:35
@pherrymason pherrymason mentioned this pull request Jan 28, 2025
32 tasks
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.

2 participants