Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Implement naming conventions in Go grammar #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

chbk
Copy link

@chbk chbk commented Mar 17, 2020

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 and types.
  • 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
Copy link
Author

chbk commented Mar 17, 2020

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-go-0
Solarized Dark
solarized-dark-go-1
One Dark
one-dark-go-0
One Dark
one-dark-go-1
Base16 Tomorrow Dark
base16-dark-go-0
Base16 Tomorrow Dark
base16-dark-go-1
Atom Dark
atom-dark-go-0
Atom Dark
atom-dark-go-1
Solarized Light
solarized-light-go-0
Solarized Light
solarized-light-go-1
One Light
one-light-go-0
One Light
one-light-go-1
Base16 Tomorrow Light
base16-light-go-0
Base16 Tomorrow Light
base16-light-go-1
Atom Light
atom-light-go-0
Atom Light
atom-light-go-1

Code snippet:

package main

import (
  "bosco"
  mule "molly"
)

// Management will be pleased

const pet string = "steeve"

func dig(b *Bag, i int) int {
  b.bismor += i
  return molly.come.here()
}

type Bag struct {
  gold, nitra, bismor int
}

func yell(say func(string)) {
  say("For Karl")
  say("Rock & Stone")
}

func main() {

  var inventory Bag
  var iron, will = true, true
  var core interface{} = 1.4
  var matrix = &core
  const leaf_lover = iota * 2

  beers := map[string]int{
    "Dark Morkite": 5,
    "Malt Rockbearer": 4,
  }

  laser := make(chan string)
  go func() {
    laser <- "jadiz"
  }()
  look_here := <-laser

  flares := []int{2, 3, 4}
  for i, f := range flares {
    if f >= 4 {
      say("Out of flares")
    } else {
      say("Lighting up")
    }
  }
}

@chbk chbk force-pushed the scopes branch 2 times, most recently from 1ca795f to 8a88bab Compare August 24, 2020 16:26
@chbk chbk force-pushed the scopes branch 2 times, most recently from 65ebb19 to 605ad5f Compare January 18, 2021 10:46
@chbk chbk marked this pull request as ready for review February 1, 2021 14:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants