Skip to content

Commit c7a4f74

Browse files
committed
tree-sitter highlight
1 parent 2980d7a commit c7a4f74

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2181
-696
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea/
2+
grammars/*
23
custom_styles/
34
gobin.toml
45
.gobin

README.md

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,82 @@ GOBIN_DEFAULT_STYLE=snazzy
365365

366366
## Custom Themes
367367

368-
You can add your own themes to gobin by adding the `custom_styles` directory to the config file and adding your themes
369-
to it.
368+
You can add your own themes to gobin by adding them to the `themes` directory.
369+
370+
### Gobin Themes
371+
372+
Gobin themes are written in TOML file format.
373+
374+
All keys specified under `colors` are variables which can be referenced by `$name` in the theme file.
375+
376+
To style UI elements you can use the `ui` key. See below for all available keys.
377+
378+
To style individual scopes you can use the `styles` key. The key is the scope and the value is the style.
379+
Make sure to quote the keys if the scope name contain a `.`.
380+
381+
```toml file=themes/name.toml
382+
name = 'name'
383+
color_scheme = 'dark' # or 'light'
384+
385+
tab_size = 4
386+
387+
[colors]
388+
text0 = '#F8F8F2'
389+
text1 = '#F8F8F2'
390+
text2 = '#8A8A8A'
391+
392+
background0 = '#212122'
393+
background1 = '#2B2B2B'
394+
background2 = '#3C3C3C'
395+
background3 = '#43494A'
396+
397+
white = '#FEFEF8'
398+
red = '#FF4352'
399+
blue = '#73FBF1'
400+
green = '#B8E466'
401+
yellow = '#FFD750'
402+
magenta = '#A578EA'
403+
gray = '#6D7070'
404+
405+
[ui]
406+
status_bar = '$text1'
407+
status_bar_background = '$background1'
408+
status_bar_active_background = '$background2'
409+
410+
code = '$text0'
411+
code_background = '$background0'
412+
413+
line_number = '$text2'
414+
line_number_background = '$background1'
415+
highlight = '$background2'
416+
417+
symbols = '$text1'
418+
symbols_background = '$background1'
419+
symbols_active_background = '$background3'
420+
synbols_kind_background = '$background1'
421+
422+
[styles]
423+
"variable" = { text = '$text' }
424+
"variable.other.member" = { text = '$red' }
425+
"function" = { text = '$blue' }
426+
"method" = { text = '$blue' }
427+
"string" = { text = '$green' }
428+
"type" = { text = '$yellow' }
429+
"keyword" = { text = '$magenta' }
430+
"comment" = { text = '$gray' }
431+
"comment.todo" = { text = '$white' }
432+
```
433+
434+
### Base16 Themes
370435

371-
The themes have to be in the following format:
436+
Base16 themes are supported and should be placed in the `themes/base16` directory.
437+
438+
See [base16](https://github.com/chriskempson/base16) for more information about base16 themes.
372439

373440
```yaml file=custom_styles/name.yaml
374441
scheme: "name"
375442
author: "author"
376-
theme: "dark" # or "light"
443+
color_scheme: "dark" # or "light"
377444
base00: "282a36"
378445
base01: "34353e"
379446
base02: "43454f"
@@ -392,9 +459,6 @@ base0E: "ff6ac1"
392459
base0F: "b2643c"
393460
```
394461

395-
See [base16](https://github.com/chriskempson/base16) for more information.
396-
397-
Or you can use the [chroma](https://github.com/topi314/chroma/tree/master/styles/embedded) XML themes.
398462

399463
## Rate Limits
400464

cli/cmd/get.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/dustin/go-humanize"
1212
"github.com/spf13/cobra"
1313
"github.com/spf13/viper"
14-
"github.com/topi314/chroma/v2/lexers"
1514

1615
"github.com/topi314/gobin/v2/internal/ezhttp"
1716
"github.com/topi314/gobin/v2/server"
@@ -207,10 +206,4 @@ Will return the document with the id of jis74978.`,
207206
}); err != nil {
208207
log.Printf("failed to register formatter flag completion func: %s", err)
209208
}
210-
211-
if err := cmd.RegisterFlagCompletionFunc("language", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
212-
return lexers.Names(true), cobra.ShellCompDirectiveNoFileComp
213-
}); err != nil {
214-
log.Printf("failed to register language flag completion func: %s", err)
215-
}
216209
}

cli/cmd/post.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
"github.com/spf13/cobra"
1616
"github.com/spf13/viper"
17-
"github.com/topi314/chroma/v2/lexers"
1817

1918
"github.com/topi314/gobin/v2/internal/cfg"
2019
"github.com/topi314/gobin/v2/internal/ezhttp"
@@ -218,10 +217,4 @@ Will post "hello world!" to the server`,
218217
if err := cmd.RegisterFlagCompletionFunc("document", documentCompletion); err != nil {
219218
log.Printf("failed to register document flag completion func: %s", err)
220219
}
221-
222-
if err := cmd.RegisterFlagCompletionFunc("languages", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
223-
return lexers.Names(true), cobra.ShellCompDirectiveNoFileComp
224-
}); err != nil {
225-
log.Printf("failed to register languages flag completion func: %s", err)
226-
}
227220
}

go.mod

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,90 +2,104 @@ module github.com/topi314/gobin/v2
22

33
go 1.23
44

5+
replace github.com/tree-sitter/go-tree-sitter => github.com/gopad-dev/go-tree-sitter v0.0.0-20241124232421-f22ab7977e8c
6+
57
require (
6-
github.com/XSAM/otelsql v0.34.0
7-
github.com/a-h/templ v0.2.778
8+
github.com/XSAM/otelsql v0.35.0
9+
github.com/a-h/templ v0.2.793
810
github.com/cespare/xxhash/v2 v2.3.0
911
github.com/dustin/go-humanize v1.0.1
12+
github.com/ebitengine/purego v0.8.1
1013
github.com/go-chi/chi/v5 v5.1.0
1114
github.com/go-chi/stampede v0.6.0
1215
github.com/go-jose/go-jose/v3 v3.0.3
1316
github.com/jackc/pgx/v5 v5.7.1
1417
github.com/jmoiron/sqlx v1.4.0
1518
github.com/mattn/go-colorable v0.1.13
1619
github.com/pelletier/go-toml/v2 v2.2.3
17-
github.com/prometheus/client_golang v1.20.4
18-
github.com/samber/slog-chi v1.11.2
20+
github.com/prometheus/client_golang v1.20.5
21+
github.com/samber/slog-chi v1.12.3
1922
github.com/spf13/cobra v1.8.1
2023
github.com/spf13/viper v1.19.0
21-
github.com/topi314/chroma/v2 v2.0.0-20240614212830-eb9beba2251d
2224
github.com/topi314/gomigrate v0.0.0-20241004214626-bb286a22f06c
2325
github.com/topi314/otelchi v0.0.0-20240303215413-6ead809329d9
2426
github.com/topi314/tint v0.0.0-20240303212505-44dd4a1b4f7f
25-
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.55.0
26-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0
27-
go.opentelemetry.io/otel v1.30.0
28-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.30.0
29-
go.opentelemetry.io/otel/exporters/prometheus v0.52.0
30-
go.opentelemetry.io/otel/metric v1.30.0
31-
go.opentelemetry.io/otel/sdk v1.30.0
32-
go.opentelemetry.io/otel/sdk/metric v1.30.0
33-
go.opentelemetry.io/otel/trace v1.30.0
34-
golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6
35-
modernc.org/sqlite v1.33.1
27+
github.com/tree-sitter/go-tree-sitter v0.24.0
28+
go.gopad.dev/go-tree-sitter-highlight v0.0.0-20241212010141-660c7ae706ef
29+
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.57.0
30+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0
31+
go.opentelemetry.io/otel v1.32.0
32+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0
33+
go.opentelemetry.io/otel/exporters/prometheus v0.54.0
34+
go.opentelemetry.io/otel/metric v1.32.0
35+
go.opentelemetry.io/otel/sdk v1.32.0
36+
go.opentelemetry.io/otel/sdk/metric v1.32.0
37+
go.opentelemetry.io/otel/trace v1.32.0
38+
golang.org/x/exp v0.0.0-20241210194714-1829a127f884
39+
modernc.org/sqlite v1.34.2
3640
)
3741

3842
require (
43+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
3944
github.com/beorn7/perks v1.0.1 // indirect
4045
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
41-
github.com/dlclark/regexp2 v1.11.4 // indirect
46+
github.com/charmbracelet/lipgloss v0.10.0 // indirect
47+
github.com/charmbracelet/log v0.4.0 // indirect
4248
github.com/felixge/httpsnoop v1.0.4 // indirect
43-
github.com/fsnotify/fsnotify v1.7.0 // indirect
49+
github.com/fsnotify/fsnotify v1.8.0 // indirect
50+
github.com/go-logfmt/logfmt v0.6.0 // indirect
4451
github.com/go-logr/logr v1.4.2 // indirect
4552
github.com/go-logr/stdr v1.2.2 // indirect
4653
github.com/google/uuid v1.6.0 // indirect
4754
github.com/goware/singleflight v0.2.0 // indirect
48-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
55+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect
4956
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
5057
github.com/hashicorp/hcl v1.0.0 // indirect
5158
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5259
github.com/jackc/pgpassfile v1.0.0 // indirect
5360
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
5461
github.com/jackc/puddle/v2 v2.2.2 // indirect
55-
github.com/klauspost/compress v1.17.10 // indirect
56-
github.com/magiconair/properties v1.8.7 // indirect
62+
github.com/klauspost/compress v1.17.11 // indirect
63+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
64+
github.com/magiconair/properties v1.8.9 // indirect
5765
github.com/mattn/go-isatty v0.0.20 // indirect
66+
github.com/mattn/go-pointer v0.0.1 // indirect
67+
github.com/mattn/go-runewidth v0.0.15 // indirect
5868
github.com/mitchellh/mapstructure v1.5.0 // indirect
69+
github.com/muesli/reflow v0.3.0 // indirect
70+
github.com/muesli/termenv v0.15.2 // indirect
5971
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6072
github.com/ncruces/go-strftime v0.1.9 // indirect
6173
github.com/prometheus/client_model v0.6.1 // indirect
62-
github.com/prometheus/common v0.60.0 // indirect
74+
github.com/prometheus/common v0.61.0 // indirect
6375
github.com/prometheus/procfs v0.15.1 // indirect
6476
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
77+
github.com/rivo/uniseg v0.4.7 // indirect
6578
github.com/sagikazarmark/locafero v0.6.0 // indirect
6679
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
6780
github.com/sourcegraph/conc v0.3.0 // indirect
6881
github.com/spf13/afero v1.11.0 // indirect
6982
github.com/spf13/cast v1.7.0 // indirect
7083
github.com/spf13/pflag v1.0.5 // indirect
7184
github.com/subosito/gotenv v1.6.0 // indirect
72-
go.opentelemetry.io/contrib v1.30.0 // indirect
73-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.30.0 // indirect
74-
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
85+
github.com/teacat/noire v1.1.0 // indirect
86+
go.opentelemetry.io/contrib v1.32.0 // indirect
87+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect
88+
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
7589
go.uber.org/multierr v1.11.0 // indirect
76-
golang.org/x/crypto v0.28.0 // indirect
77-
golang.org/x/net v0.30.0 // indirect
78-
golang.org/x/sync v0.8.0 // indirect
79-
golang.org/x/sys v0.26.0 // indirect
80-
golang.org/x/text v0.19.0 // indirect
81-
google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f // indirect
82-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
83-
google.golang.org/grpc v1.67.1 // indirect
84-
google.golang.org/protobuf v1.34.2 // indirect
90+
golang.org/x/crypto v0.31.0 // indirect
91+
golang.org/x/net v0.32.0 // indirect
92+
golang.org/x/sync v0.10.0 // indirect
93+
golang.org/x/sys v0.28.0 // indirect
94+
golang.org/x/text v0.21.0 // indirect
95+
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
96+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
97+
google.golang.org/grpc v1.68.1 // indirect
98+
google.golang.org/protobuf v1.35.2 // indirect
8599
gopkg.in/ini.v1 v1.67.0 // indirect
86100
gopkg.in/yaml.v3 v3.0.1 // indirect
87101
modernc.org/gc/v3 v3.0.0-20241004144649-1aea3fae8852 // indirect
88-
modernc.org/libc v1.61.0 // indirect
102+
modernc.org/libc v1.61.4 // indirect
89103
modernc.org/mathutil v1.6.0 // indirect
90104
modernc.org/memory v1.8.0 // indirect
91105
modernc.org/strutil v1.2.0 // indirect

0 commit comments

Comments
 (0)