Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Skript language support for VS Code / VSCodium.
- **Syntax highlighting** for `.sk` files (functions, commands, events, variables, types, effects).
- **Minecraft/Bukkit chat color codes** inside strings are rendered live using their real in-game color/style, following actual chat rendering rules (a color code resets formatting, format codes stack, `&r` resets both):
- Legacy codes `&0`-`&f` (color) and `&l/&m/&n/&o` (bold/strikethrough/underline/italic), e.g. `"&cRed &lbold text"`.
- Hex tags `<#rrggbb>`, using the *exact* color parsed out of the tag itself, e.g. `"<#f18d8d>this text is actually that pink"`.
- Hex tags `<#rrggbb>` (and the double-hash `<##rrggbb>` variant some addons use), using the *exact* color parsed out of the tag itself, e.g. `"<#f18d8d>this text is actually that pink"`.
- This part is implemented as live editor decorations (not just static theme colors), since an arbitrary hex value can't be baked into a fixed color theme.
- **Color picker support for `<#rrggbb>` tags** — VS Code's built-in color swatch/picker only recognizes a bare `#rrggbb` with nothing around it by default, so it never matched Skript's `<...>`-wrapped hex tags. A `DocumentColorProvider` is registered for `.sk` files so the swatch shows up next to `<#rrggbb>` tags and picking a new color rewrites the tag correctly (including the brackets).
- **Color picker support for `<#rrggbb>`/`<##rrggbb>` tags** — VS Code's built-in color swatch/picker only recognizes a bare `#rrggbb` with nothing around it by default, so it never matched Skript's `<...>`-wrapped hex tags. A `DocumentColorProvider` is registered for `.sk` files so the swatch shows up next to either tag form and picking a new color rewrites it correctly (including the brackets, and preserving whichever of `#`/`##` the original tag used).
- **R4TSK Dark theme** — same UI color palette as VS Code's built-in "Dark 2026" theme, with hand-authored syntax colors for Skript instead of the default ones.
- **Hover call-signature preview** — hover over a function call site, e.g. `functionname("123", true, {object})`, and see the function it resolves to:
```
Expand Down Expand Up @@ -103,7 +103,7 @@ npm run package # produce a .vsix via vsce
```

To try it locally: open this folder in VS Code / VSCodium and press F5, or install the
built `r4tsk-1.0.4.vsix` via the "Install from VSIX" command.
built `r4tsk-1.0.5.vsix` via the "Install from VSIX" command.

Open [`examples/example.sk`](examples/example.sk) for a single script touching every feature above
(doc comments, annotations, hover, `local function` scoping, color codes, diagnostics, and more).
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "r4tsk",
"displayName": "r4tsk - Skript Language Support",
"description": "Skript language support: syntax highlighting, hover call-signature preview, autocomplete, diagnostics, go-to-definition and a bundled dark theme.",
"version": "1.0.4",
"version": "1.0.5",
"publisher": "r4tsk",
"license": "UNLICENSED",
"repository": {
Expand Down
20 changes: 14 additions & 6 deletions src/providers/colorProvider.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as vscode from "vscode";
import { findStringContentRanges } from "../utils/textScanning";

const HEX_TAG = /<#([0-9a-fA-F]{6})>/g;
const HEX_TAG = /<#{1,2}([0-9a-fA-F]{6})>/g;

/**
* Lets VS Code's built-in color swatch/picker work on Skript's `<#rrggbb>`
* hex color tags. The default color detection VS Code falls back to when a
* language has no DocumentColorProvider only recognizes a bare `#rrggbb`
* with nothing around it, so it never matches Skript's `<...>` wrapper.
* (and `<##rrggbb>`) hex color tags. The default color detection VS Code
* falls back to when a language has no DocumentColorProvider only recognizes
* a bare `#rrggbb` with nothing around it, so it never matches Skript's
* `<...>` wrapper.
*/
export class SkriptColorProvider implements vscode.DocumentColorProvider {
provideDocumentColors(document: vscode.TextDocument): vscode.ColorInformation[] {
Expand All @@ -32,8 +33,15 @@ export class SkriptColorProvider implements vscode.DocumentColorProvider {
return results;
}

provideColorPresentations(color: vscode.Color): vscode.ColorPresentation[] {
return [new vscode.ColorPresentation(`<#${colorToHex(color)}>`)];
provideColorPresentations(
color: vscode.Color,
context: { document: vscode.TextDocument; range: vscode.Range }
): vscode.ColorPresentation[] {
// Preserve the original tag's "#" count (<#rrggbb> vs <##rrggbb>) rather
// than always collapsing back to a single "#" when a color is picked.
const original = context.document.getText(context.range);
const hashes = /^<(#{1,2})/.exec(original)?.[1] ?? "#";
return [new vscode.ColorPresentation(`<${hashes}${colorToHex(color)}>`)];
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/colorCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const LEGACY_COLORS: Record<string, string> = {
f: "#FFFFFF",
};

const TAG_PATTERN = /&([0-9a-fklmnor])|<#([0-9a-fA-F]{6})>/gi;
const TAG_PATTERN = /&([0-9a-fklmnor])|<#{1,2}([0-9a-fA-F]{6})>/gi;

export function scanColorRuns(text: string): ColorRun[] {
const runs: ColorRun[] = [];
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/skript.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
{ "include": "#bukkit-color-codes" },
{
"name": "constant.other.color.hextag.skript",
"match": "<#[0-9a-fA-F]{6}>"
"match": "<#{1,2}[0-9a-fA-F]{6}>"
},
{
"name": "meta.embedded.expression.skript",
Expand Down