Skip to content

Commit

Permalink
Add color toCompletionItem in VGUISchema
Browse files Browse the repository at this point in the history
  • Loading branch information
cooolbros committed Jan 13, 2025
1 parent b702517 commit 885d5c2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/server/src/VDF/VGUI/schemas/VGUISchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,21 @@ export const VGUISchema: VDFTextDocumentSchema = {
reference: {
keys: new Set(clientscheme.Colors),
match: (string) => !/\d+\s+\d+\s+\d+\s+\d+/.test(string) // Exclude colour literals
}
},
toCompletionItem: (definition) => {
if (!definition.detail) {
return undefined
}

try {
const [r, g, b] = definition.detail.split(/\s+/).map(parseFloat)
return { kind: CompletionItemKind.Color, documentation: `rgb(${r},${g},${b})` }
}
catch (error) {
console.error(error)
return undefined
}
},
},
{
type: Symbol.for("border"),
Expand Down

0 comments on commit 885d5c2

Please sign in to comment.