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

fix: Completion item label spacing for non "function-like" items #670

Closed
wants to merge 1 commit into from

Conversation

bjufre
Copy link

@bjufre bjufre commented Dec 20, 2024

Issue

When dealing with completion items the default
completion.menu.draw.components.label.text(ctx) function just returns the concatenation of ctx.label and ctx.label_detail which creates scenarios such as "MyAwesomeModinterface" which is wrongly formatted.

Solution

The solution consists in checking the ctx.kind against the internal types.CompletionItemKind table and for any kind that is not either Method, Function, Constructor or Snippet we add a space between the ctx.label and ctx.label_detail.

Examples

Before:
Screenshot 2024-12-20 at 11 23 00

After:
Screenshot 2024-12-20 at 11 23 38

## Issue

When dealing with completion items the default
`completion.menu.draw.components.label.text(ctx)` function just returns
the concatenation of `ctx.label` and `ctx.label_detail` which creates
scenarios such as "MyAwesomeModinterface" which is wrongly formatted.

## Solution

The solution consists in checking the `ctx.kind` against the internal
`types.CompletionItemKind` table and for any kind that is not either
`Method`, `Function` or `Constructor` we add a space between the
`ctx.label` and `ctx.label_detail`.
@Saghen
Copy link
Owner

Saghen commented Dec 20, 2024

This seems to be an issue with your LSP because afaict we are meant to concatenate the label and label details together without any spacing

@Saghen
Copy link
Owner

Saghen commented Dec 20, 2024

Just double checked, we're not meant to add any spacing: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemLabelDetails. Thank you though!

@Saghen Saghen closed this Dec 20, 2024
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