Open chbk opened 4 years ago
Preview of the changes in C 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:
#include <Dagobah>
#define ONE 1
/* There is no try */
typedef struct {
double rise;
char fall[sizeof(int)];
} Rock;
void move(Rock *pebble) {
static int force += 327;
pebble->levitate++;
}
int main() {
const int R2D = 2, C3P = 0;
Starfighter redfive;
redfive.target = "reactor";
int *trooper = &clone;
*trooper << 1;
goto deathstar;
char wookie[1][5] = {
{'h', 'a', 'i', 'r', 'y'}
};
deathstar:
if (padawan != NULL) {
say("Size matters not.");
}
}
Preview of the changes in C++ 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:
using namespace hillvalley;
#include <plutonium>
// We don't need roads
class DeLorean: public Car {
private:
int speed;
public:
std::string plate;
template<typename T>
void drive(T mph, ...) {
this->speed = mph;
}
};
struct Travel {
int year, month, day;
};
int main() {
auto gigawatts = 1.21;
double *power = nullptr;
power = &gigawatts;
if (*power >= 1.21) {
say("Great", "Scott");
}
static_cast<int>(*power);
DeLorean car;
car.plate = "OUTATIME";
car.drive(88);
auto add = [](int i = 0) {
return ++i;
};
Travel to {1955, 11, 5};
const char *purple[2] = {
"Calvin", "Klein"
};
}
I'm really glad to see some standardization, textmate scopes are an absolute mess (everywhere not just atom). I've been wanting them standardized for years.
would you want to help create a standard guide for Atom Textmate scopes for anyone creating a grammar? It would probably be helpful for theme makers updating their themes as well.
Also, Are the screenshots here including the other PR (the changes to the default themes)?
Yeah standardization is really needed to resolve ambiguities and missing scopes. Creating grammars and themes should be easy. You can check out this PR for a guide on scope conventions. It's still a work in progress but pretty stable now. The template is also a good starting point for creating/updating themes.
Regarding the screenshots, on the right are previews with all the PRs. On the left is the current state of Atom.
Haven't looked at the whole thing yet but,
name in entity.name
Adding name to entity is redundant as the latter is exclusively used to scope named elements.
Trailing scopes identifying the language are redundant as this information is provided by the root scope, e.g. source.java.
These are wonderful, exactly the same kind of changes I've been wanting to make. I'm looking forward to taking a deeper look into your proposed changes like having variable underneath entity.
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