atom / language-javascript

JavaScript language package for Atom
Other
194 stars 236 forks source link

Implement naming conventions in JavaScript and Regex grammars #690

Open chbk opened 3 years ago

chbk commented 3 years ago

Description of the Change

This is a rewrite of the Tree-sitter grammar to implement naming conventions for syntax scopes.

Benefits

Possible Drawbacks

Some new scopes to be added to themes. The changes aim to facilitate theme development, filling the template is enough to ensure coherent highlighting across languages, instead of painfully creating styling rules for every language separately.

Applicable Issues

Related Pull Requests

chbk commented 3 years ago

Preview of the changes with Atom's default syntax themes:

Without naming conventions
(current Tree-sitter grammar)
With naming conventions in
theme and Tree-sitter grammar
Solarized Dark
solarized-dark-js-0
Solarized Dark
solarized-dark-js-1
One Dark
one-dark-js-0
One Dark
one-dark-js-1
Base16 Tomorrow Dark
base16-dark-js-0
Base16 Tomorrow Dark
base16-dark-js-1
Atom Dark
atom-dark-js-0
Atom Dark
atom-dark-js-1
Solarized Light
solarized-light-js-0
Solarized Light
solarized-light-js-1
One Light
one-light-js-0
One Light
one-light-js-1
Base16 Tomorrow Light
base16-light-js-0
Base16 Tomorrow Light
base16-light-js-1
Atom Light
atom-light-js-0
Atom Light
atom-light-js-1

Code snippet:

import * as empire from 'galaxy'

class Terminus extends empire.Planet {
  static hologram() {
    return super.psychohistory
  }
  get plan() {
    return (
      <div class={this.axiom + 1}>
        <Council speaker="first"/>
      </div>
    )
  }
}

vault = Terminus.hologram(true)
cleonII = new empire.Trantor.Ruler()

@future
function seldonCrisis(...years) {
  let riddle = "a circle has"
  riddle += `${years[0]} no end`
  console.log(riddle)
  return [...arguments]
}

if (magnifico === undefined) {
  let search = Infinity
}

robotics.map(law =>
  law.replace(/^H(?:.*\w)\n$/i, "0")
)

/** @type {number} */
const PARSEC = 2.06265 * 1e5

export function *travel() {
  yield {
    distance: 16204 * PARSEC,
    destination: "star's end"
  }
}