antfu / vscode-pnpm-catalog-lens

Show versions inline for PNPM catalog: field
https://marketplace.visualstudio.com/items?itemName=antfu.pnpm-catalog-lens
MIT License
136 stars 2 forks source link

Each catalog has a different color #6

Open trydofor opened 2 weeks ago

trydofor commented 2 weeks ago

Clear and concise description of the problem

catalogs:
  common:     ## color:orange
    "@vueuse/core": "^11.0.3"
    "@vueuse/nuxt": "^11.0.3"
  deploy:     ## color:blue
    "@changesets/cli": "^2.27.8"
  testing:    ## color:green
    "vitest": "^2.0.5"

it would be great if catalog with different color to distinguish them.

Suggested solution

color can auto calculate or manually set

Alternative

No response

Additional context

No response

Validations

antfu commented 2 weeks ago

Un, interesting. I don't actually use named catalogs, but yeah I think this would be a nice feature. PR welcome if anyone wants to work on it

trydofor commented 2 weeks ago

I cloned this repo, and tried to the following,

predefine 10 colors in the config, and get colors by the catalog index,

"contributes": {
  "configuration": {
+     "pnpmCatalogLens.colors": {
+     "type": "array",
+     "default": ["#f69220", "#845EC2", "#D65DB1", "#2C73D2", "#0089BA", "#008F7A", "#00C7AD", "#F3C5FF", "#00C0FF", "#E6E885"],
+     "description": "text colors to diff catalogs. the first for default, #000000 for IndexOutOfBounds",
+     "items": {
+        "type": "string"
+     }
   }
const configColors = workspace.getConfiguration('pnpmCatalogLens').get('colors',['#f69220'])
const decorationsOverrideMap = new Map<string, ShallowRef<DecorationOptions[]>>();

and finally, i give up, it's hard for me to impl this feature now, i'v wrote bad smelling code :)