Skip to content

Commit

Permalink
first linting stuffies + more flalert colors
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jul 29, 2024
1 parent 9caea2c commit a96d448
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 100 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Geode for VS Code Changelog

## [v1.14.0]
- Add preliminary linting features for settings (checks for invalid setting names)
- Add support for 2.206 color tags in `FLAlertLayer` (`<ca>`, `<cc>`, `<cd>`, `<cf>`, `<cs>`)

## [v1.13.4]
- Actually include sharp binaries for all platforms, by switching to pnpm

Expand Down
44 changes: 30 additions & 14 deletions assets/flalert-colors.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,57 @@
"fileTypes": ["cpp", "hpp", "c", "h"],
"scopeName": "source.geode-flalert-literal",
"patterns": [
{
"match": "<ca>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.ca"
},
{
"match": "<cb>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.blue"
"name": "geode.flalert.cb"
},
{
"match": "<cg>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.green"
"match": "<cc>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.cc"
},
{
"match": "<cl>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.aqua"
"match": "<cd>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.cd"
},
{
"match": "<cf>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.cf"
},
{
"match": "<cg>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.cg"
},
{
"match": "<cj>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.cyan"
"name": "geode.flalert.cj"
},
{
"match": "<cy>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.yellow"
"match": "<cl>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.cl"
},
{
"match": "<co>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.orange"
"name": "geode.flalert.co"
},
{
"match": "<cp>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.cp"
},
{
"match": "<cr>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.red"
"name": "geode.flalert.cr"
},
{
"match": "<cp>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.pink"
"match": "<cs>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.cs"
},
{
"match": "<ca>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.purple"
"match": "<cy>((.*?<\/c>)|(.*)(?=\"))",
"name": "geode.flalert.cy"
}
]
}
90 changes: 62 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "geode",
"displayName": "Geode",
"description": "Utilities for the Geode Geometry Dash modding framework",
"version": "1.13.4",
"version": "1.14.0",
"engines": {
"vscode": "^1.72.0"
},
Expand Down Expand Up @@ -101,59 +101,93 @@
"configurationDefaults": {
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "geode.flalert.ca",
"settings": { "foreground": "#9632ff" }
},
{
"scope": "geode.flalert.cb",
"settings": { "foreground": "#4a52e1" }
},
{
"scope": "geode.flalert.cc",
"settings": { "foreground": "#ffff96" }
},
{
"scope": "geode.flalert.cd",
"settings": { "foreground": "#ff96ff" }
},
{
"scope": "geode.flalert.cf",
"settings": { "foreground": "#96ffff" }
},
{
"scope": "geode.flalert.cg",
"settings": { "foreground": "#40e348" }
},
{
"scope": "geode.flalert.cj",
"settings": { "foreground": "#32c8ff" }
},
{
"scope": "geode.flalert.cl",
"settings": { "foreground": "#60abef" }
},
{
"scope": "geode.flalert.co",
"settings": { "foreground": "#ffa54b" }
},
{
"scope": "geode.flalert.cp",
"settings": { "foreground": "#ff00ff" }
},
{
"scope": "geode.flalert.cr",
"settings": { "foreground": "#ff5a5a" }
},
{
"scope": "geode.flalert.cs",
"settings": { "foreground": "#ffdc41" }
},
{
"scope": "geode.flalert.cy",
"settings": { "foreground": "#ffff00" }
},
{
"scope": "geode.flalert.blue",
"settings": {
"foreground": "#4a52e1"
}
"settings": { "foreground": "#4a52e1" }
},
{
"scope": "geode.flalert.green",
"settings": {
"foreground": "#40e348"
}
"settings": { "foreground": "#40e348" }
},
{
"scope": "geode.flalert.aqua",
"settings": {
"foreground": "#60abef"
}
"settings": { "foreground": "#60abef" }
},
{
"scope": "geode.flalert.cyan",
"settings": {
"foreground": "#32c8ff"
}
"settings": { "foreground": "#32c8ff" }
},
{
"scope": "geode.flalert.yellow",
"settings": {
"foreground": "#ffff00"
}
"settings": { "foreground": "#ffff00" }
},
{
"scope": "geode.flalert.orange",
"settings": {
"foreground": "#ffa54b"
}
"settings": { "foreground": "#ffa54b" }
},
{
"scope": "geode.flalert.red",
"settings": {
"foreground": "#ff5a5a"
}
"settings": { "foreground": "#ff5a5a" }
},
{
"scope": "geode.flalert.pink",
"settings": {
"foreground": "#ff00ff"
}
"settings": { "foreground": "#ff00ff" }
},
{
"scope": "geode.flalert.purple",
"settings": {
"foreground": "#9632ff"
}
"settings": { "foreground": "#9632ff" }
}
]
}
Expand Down
11 changes: 4 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { getActiveProject, getOpenedProjects } from "./project/project";
import { env } from "vscode";
import { Uri } from "vscode";
import { CCColor3bProvider, CCColor4bProvider } from "./project/color";
import { SettingHover, SpriteHoverPreview } from "./project/hover";
import { SpriteHoverPreview } from "./project/hover";
import { registerLinters } from "./project/lint";

export async function activate(context: ExtensionContext) {
const channel = window.createOutputChannel("Geode");
Expand Down Expand Up @@ -132,12 +133,8 @@ export async function activate(context: ExtensionContext) {
new SpriteHoverPreview(),
),
);
context.subscriptions.push(
languages.registerHoverProvider(
{ language: "cpp" },
new SettingHover(),
),
);

registerLinters(context);

getOutputChannel().appendLine(
`Open Geode projects: ${getOpenedProjects()
Expand Down
8 changes: 4 additions & 4 deletions src/project/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CCColorProvider implements DocumentColorProvider {

private parseColor(color: string): Color | undefined {
const bytes = color.match(MATCH_COLOR_BYTE);
getOutputChannel().appendLine(`got ${bytes?.length} matches`);
// getOutputChannel().appendLine(`got ${bytes?.length} matches`);
if (!bytes || bytes.length < 3 || bytes.length > (this.rgba ? 4 : 3)) {
getOutputChannel().appendLine(`didnt barse color ${color}`);
// getOutputChannel().appendLine(`didnt barse color ${color}`);
return undefined;
}
return new Color(
Expand Down Expand Up @@ -64,9 +64,9 @@ class CCColorProvider implements DocumentColorProvider {
line.toLowerCase().includes("color") ||
line.includes(this.rgba ? "ccc4" : "ccc3")
) {
getOutputChannel().appendLine(`${line} passed the test`);
// getOutputChannel().appendLine(`${line} passed the test`);
for (const match of line.matchAll(this.generateRegex())) {
getOutputChannel().appendLine(`${match[0]} matched`);
// getOutputChannel().appendLine(`${match[0]} matched`);
const color = this.parseColor(match[0]);
if (match.index && color) {
ret.push(
Expand Down
37 changes: 1 addition & 36 deletions src/project/hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class SpriteHoverPreview implements HoverProvider {
let item: Option<Item<ItemType>>;
if (match.text.endsWith("_spr")) {
const name = match.text.substring(1, match.text.length - 5);
const project = getProjectFromDocument(document);
const project = getProjectFromDocument(document.uri);
if (!project) {
return undefined;
}
Expand Down Expand Up @@ -106,38 +106,3 @@ export class SpriteHoverPreview implements HoverProvider {
return undefined;
}
}

export class SettingHover implements HoverProvider {
provideHover(
document: TextDocument,
position: Position,
token: CancellationToken,
): ProviderResult<Hover> {
const project = getProjectFromDocument(document);
if (!project || !project.modJson.settings) {
return undefined;
}
const match = getMatch(
document,
position,
/(?<=[gs]etSettingValue.*?\(\s*")[a-z0-9\-]+(?="[^\)]*\))/g,
);
if (match) {
if (match.text in project.modJson.settings) {
const rawModJson = readFileSync(
join(project.path, "mod.json"),
).toString();
const setting = project.modJson.settings[match.text];
return new Hover(
`# ${setting.name ?? match.text}\n\n${setting.description ?? "No Description"}` +
`\n\n[Go to Definition](/${project.path}/mod.json#${getLineOfString(rawModJson, match.text)})`,
match.range,
);
} else {
// todo: figure out how to make this a linter warning
return new Hover(`Unknown setting ${match.text}`, match.range);
}
}
return undefined;
}
}
Loading

0 comments on commit a96d448

Please sign in to comment.