Skip to content

fix!: autocompletion window components alignment #51

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

Merged
merged 1 commit into from
Oct 10, 2024
Merged

Conversation

lopi-py
Copy link
Contributor

@lopi-py lopi-py commented Oct 9, 2024

Before
image
After
image

I have a custom windows.autocomplete.draw function:

draw = function(ctx)
  return {
    {
      ctx.item.label,
      ctx.kind == "Snippet" and "~" or nil,
      fill = true,
      hl_group = ctx.deprecated and "BlinkCmpLabelDeprecated" or "BlinkCmpLabel",
    },
    " ",
    { ctx.kind, hl_group = "BlinkCmpKind" .. ctx.kind },
  }
end

Notes

  • I've removed windows.autocomplete.min_width and windows.autocomplete.max_width since it's way easier to maintain the alignment without those, but in compensation, max_width component option was added:
draw = function(ctx)
  return {
    {
      ctx.item.label,
      ctx.kind == "Snippet" and "~" or nil,
      fill = true,
      max_width = 5,
      hl_group = ctx.deprecated and "BlinkCmpLabelDeprecated" or "BlinkCmpLabel",
    },
    " ",
    { ctx.kind, hl_group = "BlinkCmpKind" .. ctx.kind },
  }
end

image
Also it feels weird to have unnecessary blank spacing with the windows.autocomplete.min_width option

  • This PR allows for multiple fill components
  • Added padding for both left and right sides of the display item

Copy link
Owner

@Saghen Saghen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! The multiple fills and max_width especially make layouts much easier. One small change, a rebase and I'll merge

@lopi-py lopi-py marked this pull request as ready for review October 10, 2024 05:02
@lopi-py
Copy link
Contributor Author

lopi-py commented Oct 10, 2024

I had fun with git 🥹.
It should be ready now @Saghen, also would you accept a PR to add snippets indicators and the draw function I made?
image

@Saghen
Copy link
Owner

Saghen commented Oct 10, 2024

Yep I would, should they be at the beginning instead?

@lopi-py
Copy link
Contributor Author

lopi-py commented Oct 10, 2024

It feels like its missaligned with the other items, actually, the snippet indicator is taken from nvim-cmp

@Saghen Saghen merged commit a4f5f8e into Saghen:main Oct 10, 2024
@Saghen
Copy link
Owner

Saghen commented Oct 10, 2024

Thank you!

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