Skip to content

Commit

Permalink
feat(options): add option to disable icon pack sync (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
nekowinston committed Mar 15, 2024
1 parent 91851ec commit 54f5685
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
9 changes: 7 additions & 2 deletions packages/catppuccin-vsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@
"type": "object",
"default": {},
"markdownDescription": "Custom color overrides. Assign your own hex codes to palette colors. See [the docs](https://github.com/catppuccin/vscode#override-palette-colors) for reference.",
"$ref": "https://cdn.jsdelivr.net/gh/catppuccin/vscode@catppuccin-vsc-v3.11.2/packages/catppuccin-vsc/schemas/colorOverrides.schema.json"
"$ref": "https://cdn.jsdelivr.net/gh/catppuccin/vscode@catppuccin-vsc-v3.12.0/packages/catppuccin-vsc/schemas/colorOverrides.schema.json"
},
"catppuccin.customUIColors": {
"type": "object",
"default": {},
"markdownDescription": "Customize UI colors. Map `workbench.colorCustomizations` to palette colors. See [the docs](https://github.com/catppuccin/vscode#use-palette-colors-on-workbench-elements-ui) for reference.",
"$ref": "https://cdn.jsdelivr.net/gh/catppuccin/vscode@catppuccin-vsc-v3.11.2/packages/catppuccin-vsc/schemas/customUIColors.schema.json"
"$ref": "https://cdn.jsdelivr.net/gh/catppuccin/vscode@catppuccin-vsc-v3.12.0/packages/catppuccin-vsc/schemas/customUIColors.schema.json"
},
"catppuccin.accentColor": {
"type": "string",
Expand Down Expand Up @@ -139,6 +139,11 @@
"type": "boolean",
"default": false,
"description": "Controls whether borders should be enabled on some additional UI elements."
},
"catppuccin.syncWithIconPack": {
"type": "boolean",
"default": true,
"markdownDescription": "Controls whether to sync the currently active Catppuccin flavor with the [Catppuccin Icon Pack](https://github.com/catppuccin/vscode-icons)"
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions packages/catppuccin-vsc/src/hooks/updatePackageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ const configuration = (version: string) => {
description:
"Controls whether borders should be enabled on some additional UI elements.",
},
"catppuccin.syncWithIconPack": {
type: "boolean",
default: true,
markdownDescription:
"Controls whether to sync the currently active Catppuccin flavor with the [Catppuccin Icon Pack](https://github.com/catppuccin/vscode-icons)",
},
},
};
};
Expand Down
17 changes: 10 additions & 7 deletions packages/catppuccin-vsc/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ export const activate = async (context: ExtensionContext) => {
mocha: Uri.joinPath(base, "themes", "mocha.json"),
};

const config = utils.getConfiguration();

// regenerate on a fresh install if non-default config is set
if ((await utils.isFreshInstall(context)) && !utils.isDefaultConfig()) {
utils.updateThemes(
utils.getConfiguration(),
paths,
utils.UpdateTrigger.FRESH_INSTALL,
);
utils.updateThemes(config, paths, utils.UpdateTrigger.FRESH_INSTALL);
}

context.subscriptions.push(
Expand All @@ -31,12 +29,17 @@ export const activate = async (context: ExtensionContext) => {
);
}
// call the icon pack sync when the theme changes
if (event.affectsConfiguration("workbench.colorTheme")) {
if (
event.affectsConfiguration("workbench.colorTheme") &&
config.syncWithIconPack
) {
utils.syncToIconPack();
}
}),
);

// call the icon pack sync on activation
utils.syncToIconPack();
if (config.syncWithIconPack) {
utils.syncToIconPack();
}
};
1 change: 1 addition & 0 deletions packages/catppuccin-vsc/src/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const defaultOptions: ThemeOptions = {
bracketMode: "rainbow",
extraBordersEnabled: false,
customUIColors: {},
syncWithIconPack: true,
};

export const compileTheme = (
Expand Down
5 changes: 5 additions & 0 deletions packages/catppuccin-vsc/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export type ThemeOptions = {
* See [the docs](https://github.com/catppuccin/vscode/tree/main/packages/catppuccin-vsc#use-palette-colors-on-workbench-elements-ui) for reference.
*/
customUIColors: CustomUIColors;

/**
* Controls whether to sync the currently active Catppuccin flavor with the [Catppuccin Icon Pack](https://github.com/catppuccin/vscode-icons)
*/
syncWithIconPack: boolean;
};

export type ThemePaths = {
Expand Down
3 changes: 2 additions & 1 deletion packages/catppuccin-vsc/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export const getConfiguration = (): ThemeOptions => {
bracketMode: config.get<CatppuccinBracketMode>("bracketMode"),
extraBordersEnabled: config.get<boolean>("extraBordersEnabled"),
customUIColors: config.get<CustomUIColors>("customUIColors"),
};
syncWithIconPack: config.get<boolean>("syncWithIconPack"),
} satisfies Partial<ThemeOptions>;
return {
...defaultOptions,
...filterObject(options, ([, value]) => value !== undefined),
Expand Down

0 comments on commit 54f5685

Please sign in to comment.