New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve syntax highlighting colors #4572
Conversation
Current coverage is 88.79% (diff: 100%)@@ master #4572 diff @@
==========================================
Files 192 192
Lines 13646 13796 +150
Methods 1413 1442 +29
Messages 0 0
Branches 3153 3211 +58
==========================================
+ Hits 12102 12250 +148
- Misses 1544 1546 +2
Partials 0 0
|
f10ce4a
to
8c946b7
Compare
|
Not really sure about changing to yellow or the bold keywords? Most of this is personal preference (for me and you) |
8c946b7
to
93a478b
Compare
It sure is. What I can say is:
At least it's better than before, though? |
I think I'd be 👍 with the other changes. I think we can merge that part first and then make the other change a separate PR for further discussion?
There's probably a lot of people who are used to the old one so if we are going to change it, maybe we can get more feedback before it's changed like that? |
That's a good idea, but I don't know how to do that.
Definitely! :) |
So I would revert the change for let defs = {
string: chalk.red,
punctuator: chalk.bold,
curly: chalk.green,
parens: chalk.blue.bold,
square: chalk.yellow,
keyword: chalk.cyan,
number: chalk.magenta,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.white.bgRed.bold,
// new stuff
marker: chalk.red.bold,
gutter: chalk.grey,
// bracket: intentionally omitted.
capitalized: chalk.yellow,
jsx_tag: chalk.yellow // same color instead of chalk.yellow.dim,
}; |
comment: chalk.grey, | ||
invalid: chalk.white.bgRed.bold, | ||
gutter: chalk.grey, | ||
marker: chalk.red.bold, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone want to play around with these colors? All you need to do is edit this block of code!
Quick-start:
git clone https://github.com/lydelll/babel.git
git checkout nicer-syntax-highlighting
make bootstrap
- Edit
packages/babel-code-frame/lib/index.js
. - Try it out with
node test.js
. - Post your changes and a screen shot here.
// test.js
const codeFrame = require('./packages/babel-code-frame/lib/')
const lines = `
class MyComponent extends React.Component {
render() {
const format = (title) => title.replace(/,$/, '') + 1337;
return (
<h1 className="test">
{format(this.props.title)}
</h1>
);
} // comment
} # invalid
`.trim()
console.log(codeFrame(lines, 6, 10, {highlightCode: true, linesAbove: 9, linesBelow: 9}))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just used a babel project, wrote the code you pasted before and then ran it by editing node_modules
Wow, the colors look much nicer on your computer! Note that the following rules you added are not applied in your screenshot (I guess you didn't change back to using different token types for every type of bracket): curly: chalk.green,
parens: chalk.blue.bold,
square: chalk.yellow, |
What does my version look like on your computer? |
93a478b
to
b84cef7
Compare
I'm using https://github.com/voronianski/oceanic-next-color-scheme in sublime and in iTerm so that could be a reference |
Here's another alternative: |
Yeah I think the changes to brackets to remove color were fine. Having red as string is odd but the background error color is red so it's not too bad Ok but are React Components the other yellow? it seemed like before it was the dim one even when jsx was caps |
OK.
Sorry, I meant the
The idea is that |
Basically what I had in #4572 (comment) was keep everything the same and introduce less colors (use one yellow for caps/jsx) as a initial pr. And graying out the brackets does that as well |
Yeah that's what I meant - it was 2 different colors but we could just use 1? I think it would basically be the same as the first one - removes unnecessary ones for brackets like you mentioned, and adds them for caps/jsx. |
Sorry, I don’t really get it – is my last screen shot fine, or do I need to make more adjustments? :) |
Yeah 👍 |
- Highlight the error location markers in bold red. - Dim the line number gutter with grey. - Don't highlight brackets. Few editor color schemes do. - Add JSX tag highlighting. - Don't highlight punctuators with bold. That looks bad on Ubuntu based systems. Instead, highlight them the same way as JSX tags, which results in really nice JSX highlighting. - Highlight capitalized variable names. - Make invalid tokens stand out with a red background.
b84cef7
to
fa1de5c
Compare
@hzoo I've updated the PR now, so that it looks like in the last screen shot. |
That looks like expected to me. Just tell me if there's anything more you'd like to be changed! :) |
- Red makes it look like something is wrong with the string. - On Ubuntu-based systems, it looks kinda broken. - The error markers (`>` and `^`) as well as invalid tokens are already marked with red. By not having strings red, the most important information -- the error location -- is more visible. This is a continuation of commit fa1de5c (PR babel#4572).
- Red makes it look like something is wrong with the string. - On Ubuntu-based systems, it looks kinda broken. - The error markers (`>` and `^`) as well as invalid tokens are already marked with red. By not having strings red, the most important information -- the error location -- is more visible. This is a continuation of commit fa1de5c (PR babel#4572).
Ok, I submitted #4579 for the color change. |
- Red makes it look like something is wrong with the string. - On Ubuntu-based systems, it looks kinda broken. - The error markers (`>` and `^`) as well as invalid tokens are already marked with red. By not having strings red, the most important information -- the error location -- is more visible. This is a continuation of commit fa1de5c (PR #4572).
- Highlight the error location markers in bold red. - Dim the line number gutter with grey. - Don't highlight brackets. Few editor color schemes do. - Add JSX tag highlighting. - Don't highlight punctuators with bold. That looks bad on Ubuntu based systems. Instead, highlight them the same way as JSX tags, which results in really nice JSX highlighting. - Highlight capitalized variable names. - Make invalid tokens stand out with a red background.
- Red makes it look like something is wrong with the string. - On Ubuntu-based systems, it looks kinda broken. - The error markers (`>` and `^`) as well as invalid tokens are already marked with red. By not having strings red, the most important information -- the error location -- is more visible. This is a continuation of commit fa1de5c (PR babel#4572).
Before:
After: