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

style(tailwind): use block vs. icon for Color items #544

Merged
merged 3 commits into from
Dec 16, 2024

Conversation

minusfive
Copy link
Contributor

Use block characters instead of an icon for the Color item "kind" to make swatches more usable.

Old

Screenshot 2024-12-13 at 14 49 23

New

Screenshot 2024-12-13 at 15 02 49

@Saghen
Copy link
Owner

Saghen commented Dec 13, 2024

Looks good! Although I don't think we should replace the icon for all color items. This should be a special case for tailwind instead

@minusfive
Copy link
Contributor Author

Looks good! Although I don't think we should replace the icon for all color items. This should be a special case for tailwind instead

Agree, let me correct it.

@minusfive minusfive force-pushed the use-block-for-color-kind branch from 3f77374 to 81cf099 Compare December 13, 2024 21:00
@minusfive

This comment has been minimized.

@minusfive minusfive changed the title style(appearance): use block vs. icon for Color kind style(tailwind): use block vs. icon for Color items Dec 13, 2024
@minusfive

This comment has been minimized.

@minusfive minusfive force-pushed the use-block-for-color-kind branch from 81cf099 to 289d7b2 Compare December 14, 2024 03:45
@minusfive
Copy link
Contributor Author

minusfive commented Dec 14, 2024

Alright @Saghen, think it's ready for review now. I took the opportunity to clean up some of the code a bit, hope it's OK.

@minusfive
Copy link
Contributor Author

@Saghen LMK if you'd like me to roll back some of the unnecessary changes, or whether you'd prefer I go in a different direction. Lay it on me, I won't be offended ;)

@Saghen Saghen merged commit 1502c75 into Saghen:main Dec 16, 2024
@Saghen
Copy link
Owner

Saghen commented Dec 16, 2024

Thanks!

@nmfirdausw
Copy link

nmfirdausw commented Dec 21, 2024

@Saghen, @minusfive
Can we make the block is configurable, I want to use this ■ instead of block.

@minusfive
Copy link
Contributor Author

@Saghen, @minusfive

Can we make the block is configurable, I want to use this ■ instead of block.

I'd originally made it configurable through the Kinds array, but that was before I learned Kinds are actually defined at the protocol level https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/, which I believe is one of the reasons @Saghen refactored my original.

Wouldn't be too hard to add a config option I'd think. Unfortunately I'll be tied up for the next couple of weeks, but if I find the time I'll give it a shot.

Or feel free to submit your own PR!

@idr4n
Copy link

idr4n commented Dec 21, 2024

@nmfirdausw I wanted the same and I got it working with the following:

opts = {
  completion = {
    menu = {
      draw = {
        components = {
          kind_icon = {
            text = function(ctx)
              if require("blink.cmp.completion.windows.render.tailwind").get_hex_color(ctx.item) then
                return "󱓻"
              end
              return ctx.kind_icon .. ctx.icon_gap
            end,
          },
        },
      },
    },
  },
}

@minusfive
Copy link
Contributor Author

@nmfirdausw I wanted the same and I got it working with the following:

opts = {

  completion = {

    menu = {

      draw = {

        components = {

          kind_icon = {

            text = function(ctx)

              if require("blink.cmp.completion.windows.render.tailwind").get_hex_color(ctx.item) then

                return "󱓻"

              end

              return ctx.kind_icon .. ctx.icon_gap

            end,

          },

        },

      },

    },

  },

}

I feel like this is the best option, tbh. Not sure it's worth polluting the config table with a single orphan icon outside of the kinds array. Component overrides are very powerful and let you do whatever you want.

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.

4 participants