Skip to content

Increase token granularity for improved syntax highlighting #1623

@atomiks

Description

@atomiks

It would be cool to add more tokens so different parts of the code can be highlighted differently. Prism seems more granular than CodeMirror, but it's still missing some nice tokens compared to Atom and VS Code.

For JavaScript, it would be nice to have these:

  • token parameter
function add(a, b) { // <-- `a` and `b` receive `parameter`
  return a + b;
}
  • token property definition and token property access
const obj = {
  example: true // <-- `example` receives `property` and `definition`
};
obj.example; // <-- `example` receives `property` and `access`
  • token function method
this.func(); // `func` receives `method` if being called on an object
  • token keyword module

All keywords here should receive the module token.

import { thing as thingy } from 'thing';
export default thingy;
  • token keyword special

"special"(?) keywords like this

  • token variable dom
window
document
navigator
performance
localStorage
  • token console
console.log('hello'); // <-- `console` receives this token
  • token operator spread
const copy = [...arr]; // <- `...` receives this token

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions