aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-10-05 16:47:32 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-10-05 16:47:32 +0200
commitada6a68b4f25c912705542a6b03aae7ffffb5e99 (patch)
tree63ffb7d4c2f6c8ce194f90f6b3568b9c08286bf9 /main.go
parent78af329f2c7bc1739bcd36baf45ab95aaff43434 (diff)
downloadcerrado-ada6a68b4f25c912705542a6b03aae7ffffb5e99.tar.gz
cerrado-ada6a68b4f25c912705542a6b03aae7ffffb5e99.tar.bz2
cerrado-ada6a68b4f25c912705542a6b03aae7ffffb5e99.zip
feat: Make syntax highlight configurable
Now cerrado has configurable theme through "syntax-highlight".
Diffstat (limited to 'main.go')
-rw-r--r--main.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/main.go b/main.go
index 8bf5141..918b794 100644
--- a/main.go
+++ b/main.go
@@ -11,6 +11,7 @@ import (
"os/signal"
"time"
+ "github.com/alecthomas/chroma/v2/styles"
"golang.org/x/crypto/bcrypt"
"git.gabrielgio.me/cerrado/pkg/config"
@@ -71,9 +72,7 @@ func key() error {
}
func run(ctx context.Context) error {
- var (
- configPath = flag.String("config", "/etc/cerrado.scfg", "File path for the configuration file")
- )
+ configPath := flag.String("config", "/etc/cerrado.scfg", "File path for the configuration file")
flag.Parse()
@@ -83,6 +82,17 @@ func run(ctx context.Context) error {
return err
}
+ // checking chroma configurationo
+
+ if _, ok := styles.Registry[configRepo.GetSyntaxHighlight()]; !ok {
+ slog.Warn(
+ "Invalid Syntax highlight selected",
+ "invalid-style", configRepo.GetSyntaxHighlight(),
+ "using", "monokailight",
+ )
+ styles.Fallback = styles.Registry["monokailight"]
+ }
+
// services
gitService := service.NewGitService(configRepo)