Skip to content

Commit

Permalink
Highlight vars nicely.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 22, 2024
1 parent 15aad6a commit c47f45c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions site/token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
* 2. `export/etc` are highlighted as control-flow keywords
* 3. Class fields are highlighted as variables
* 4. Highlight function/class def names properly
* 5. Highlight var/let/const names properly
*
*/

export const rules = [
// { token: "identifier.ts", foreground: "9CDCFE" },
{ token: "variable.property.ts", foreground: "9CDCFE" },
// { token: "function.ts", foreground: "DCDCAA" },
{ token: "constant.ts", foreground: "4FC1FF" },
{ token: "variable.ts", foreground: "9CDCFE" },
{ token: "method.ts", foreground: "DCDCAA" },
// { token: "delimiter.ts", foreground: "569CD6" },
];
Expand Down Expand Up @@ -81,14 +84,22 @@ export const tokenProvider = {
{ token: 'keyword' },
{
cases: {
'$1~function\\s+': { token: 'method' },
'$1~class\\s+': { token: 'type.identifier' },
'': { token: 'string.sql' },
'$1~function\\s+': 'method',
'$1~class\\s+': 'type.identifier',
'@default': 'identifier',
}
},
{ token: '@rematch' },
]],

// highlight var/const/let defs nicely
[/((?:const|let|var)\s+)(#?[\w$]+)/, ['keyword', {
cases: {
'$1~const\\s+': 'constant',
'@default': 'variable',
}
}]],

// identifiers and keywords
[/#?[a-z_$][\w$]*/, {
cases: {
Expand Down

0 comments on commit c47f45c

Please sign in to comment.