diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-10-05 16:47:32 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-10-05 16:47:32 +0200 |
commit | ada6a68b4f25c912705542a6b03aae7ffffb5e99 (patch) | |
tree | 63ffb7d4c2f6c8ce194f90f6b3568b9c08286bf9 /main.go | |
parent | 78af329f2c7bc1739bcd36baf45ab95aaff43434 (diff) | |
download | cerrado-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.go | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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) |