FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Implement naming conventions in JavaScript and Regex grammars by chbk · Pull Request #690 · atom/language-javascript · GitHub

This repository was archived by the owner on Dec 15, 2022. It is now read-only.
/ language-javascript Public archive

Implement naming conventions in JavaScript and Regex grammars - #690

Open
chbk wants to merge 1 commit into
atom:masterfrom
chbk:scopes
Open

chbk wants to merge 1 commit into
atom:masterfrom
chbk:scopes

Conversation

chbk commented Jan 12, 2021 •
edited
Loading

Copy link
Copy Markdown

Description of the Change

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

Benefits

  • Many new scopes added to make the grammar explicit and exhaustive.
  • Notable improvements on punctuation, types, and regex patterns.
  • Highlighting to be consistent with other languages.

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 Jan 12, 2021 •
edited
Loading

Copy link
Copy Markdown
Author

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
One Dark
One Dark
Base16 Tomorrow Dark
Base16 Tomorrow Dark
Atom Dark
Atom Dark
Solarized Light
Solarized Light
One Light
One Light
Base16 Tomorrow Light
Base16 Tomorrow Light
Atom Light
Atom Light

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"
  }
}

icecream17 added a commit to icecream17/pulsar that referenced this pull request Oct 2, 2022
The non-tree sitter version is almost completely copied so nothing to say there.

There are some inconsistencies/missing operators in the tree-sitter version, for example:
- `this`
- `new.target`
- `import.meta`
- The keyword.operator order looks more wrong the more I look at it but that's for another day because of the possible scope regularity change in the future: atom/language-javascript#690
- btw atom/language-javascript#691 looks good to me I should probably do that

Even though tree-sitter will have some above changes I added the new operators (`** **= ?? &&= ||= ??= void`) anyway.
Well `void` is not new it's just missing.
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators for a list of operators. Of course while the comma is technically an operator, hopefully it's used more to separate elements in arrays or properties in objects.

Also `delete` is an operator not control.
icecream17 mentioned this pull request Oct 2, 2022
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL