Skip to content

Commit bd6e5c3

Browse files
committed
Pick up updates to syntax highlighting themes from shiki
- New location for list of themes - Add support for 3-digit hex colors - Use better default theme for github-dark-dim and solarized-light
1 parent bc31522 commit bd6e5c3

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Syntax highlighting is supported via [shiki](https://github.com/shikijs/shiki/),
7171
git config split-diffs.syntax-highlighting-theme <name>
7272
```
7373

74-
The supported syntax highlighting themes are listed at https://github.com/shikijs/shiki/blob/v0.9.3/docs/themes.md
74+
The supported syntax highlighting themes are listed at https://github.com/shikijs/textmate-grammars-themes/tree/main/packages/tm-themes#tm-themes
7575

7676
You can disable syntax highlighting by setting the name to empty:
7777

@@ -175,11 +175,11 @@ git config split-diffs.theme-name monochrome-light
175175

176176
Tested by measuring the time it took to pipe the output `git log -p` to `/dev/null` via `git-split-diffs` with the default theme:
177177

178-
| Features enabled | ms/kloc |
179-
| ----------------------------------------------------- | --------------- |
180-
| Everything | 45 |
181-
| No syntax highlighting | 15 |
182-
| No syntax highlighting, no inline change highlighting | 13 |
178+
| Features enabled | ms/kloc |
179+
| ----------------------------------------------------- | ------- |
180+
| Everything | 45 |
181+
| No syntax highlighting | 15 |
182+
| No syntax highlighting, no inline change highlighting | 13 |
183183

184184
## Troubleshooting
185185

screenshots/github-dark-dim.png

13.7 KB
Loading

screenshots/solarized-light.png

29 KB
Loading

src/themes.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,24 @@ export type ThemeColor = {
7777
* The hex string is of the format #rrggbb(aa)
7878
*/
7979
function hexToRgba(hex: string): ColorRgba {
80-
assert.ok(hex.length === 7 || hex.length === 9);
80+
assert.ok(hex.length === 7 || hex.length === 9 || hex.length === 4, hex);
8181

82-
let hexNo = parseInt(hex.slice(1), 16);
82+
hex = hex.slice(1);
83+
84+
let hexNo = parseInt(hex, 16);
85+
let bits = hex.length === 3 ? 4 : 8;
8386

8487
let a = 255;
85-
if (hex.length === 9) {
88+
if (hex.length === 8) {
8689
a = hexNo & 0xff;
87-
hexNo >>>= 8;
90+
hexNo >>>= bits;
8891
}
8992

9093
const b = hexNo & 0xff;
91-
hexNo >>>= 8;
94+
hexNo >>>= bits;
9295

9396
const g = hexNo & 0xff;
94-
hexNo >>>= 8;
97+
hexNo >>>= bits;
9598

9699
const r = hexNo & 0xff;
97100

themes/github-dark-dim.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"SYNTAX_HIGHLIGHTING_THEME": "github-dark",
2+
"SYNTAX_HIGHLIGHTING_THEME": "github-dark-dimmed",
33
"DEFAULT_COLOR": {
44
"color": "#768390",
55
"backgroundColor": "#22282d"

themes/solarized-light.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"SYNTAX_HIGHLIGHTING_THEME": "solarized-dark",
2+
"SYNTAX_HIGHLIGHTING_THEME": "solarized-light",
33
"DEFAULT_COLOR": {
44
"color": "#657b83",
55
"backgroundColor": "#fdf6e3"

0 commit comments

Comments
 (0)