diff --git a/go.mod b/go.mod index 3e0a021..9c21b75 100644 --- a/go.mod +++ b/go.mod @@ -7,10 +7,10 @@ toolchain go1.26.5 require ( charm.land/bubbles/v2 v2.1.1 charm.land/bubbletea/v2 v2.0.8 + charm.land/glamour/v2 v2.0.1 charm.land/lipgloss/v2 v2.0.5 github.com/atotto/clipboard v0.1.4 github.com/caarlos0/env/v11 v11.3.1 - github.com/charmbracelet/glamour v0.10.0 github.com/charmbracelet/log v0.4.2 github.com/charmbracelet/x/editor v0.1.0 github.com/dustin/go-humanize v1.0.1 diff --git a/go.sum b/go.sum index 6cb6801..e454080 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ charm.land/bubbles/v2 v2.1.1 h1:7r55WzBxpo/R3z98hGmY7KKPd3ET6vsf0Fb9sDHOV60= charm.land/bubbles/v2 v2.1.1/go.mod h1:GE6M31gaWZVXzGw73OeuTTgy4lX+OtkH0E5ymnNsHxo= charm.land/bubbletea/v2 v2.0.8 h1:SxTJMhCAI3lbPmy4SgX5LWZ24AdINr4I6UEqzZvYJuY= charm.land/bubbletea/v2 v2.0.8/go.mod h1:2SkdgoTXluXJHOUwAoRlRXF/28vklb1rFl6GcgV1/ss= +charm.land/glamour/v2 v2.0.1 h1:xl+r00A4aJWU0z8fgwKd9fQQ4rsphqGUzuEiXZP5n+c= +charm.land/glamour/v2 v2.0.1/go.mod h1:jo9z8XqVKPeEFMVdvCRLGk++RyJ3CdUwgNr7EvXLw3k= charm.land/lipgloss/v2 v2.0.5 h1:kbNxgeeUOYv5J0YdpxFjfvf3dFvqH8Aci4zB6xqFtrY= charm.land/lipgloss/v2 v2.0.5/go.mod h1:9oqhxt4yxIMe6q5A4kHr44DremZk7J9UNh74GlWa5nc= github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE= @@ -22,8 +24,6 @@ github.com/caarlos0/env/v11 v11.3.1 h1:cArPWC15hWmEt+gWk7YBi7lEXTXCvpaSdCiZE2X5m github.com/caarlos0/env/v11 v11.3.1/go.mod h1:qupehSf/Y0TUTsxKywqRt/vJjN5nz6vauiYEUUr8P4U= github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q= github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q= -github.com/charmbracelet/glamour v0.10.0 h1:MtZvfwsYCx8jEPFJm3rIBFIMZUfUJ765oX8V6kXldcY= -github.com/charmbracelet/glamour v0.10.0/go.mod h1:f+uf+I/ChNmqo087elLnVdCiVgjSKWuXa/l6NU2ndYk= github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0ro+SZZiIZD7msJyA+NjkCNNavuiPBLgerbOziE= github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= diff --git a/main.go b/main.go index 1ab2721..000d99d 100644 --- a/main.go +++ b/main.go @@ -16,13 +16,12 @@ import ( "mvdan.cc/sh/v3/shell" "github.com/caarlos0/env/v11" - "github.com/charmbracelet/glamour" - "github.com/charmbracelet/glamour/styles" + "charm.land/glamour/v2" + "charm.land/glamour/v2/styles" "github.com/charmbracelet/glow/v2/ui" "github.com/charmbracelet/glow/v2/utils" "github.com/charmbracelet/log" gap "github.com/muesli/go-app-paths" - "github.com/muesli/termenv" "github.com/spf13/cobra" "github.com/spf13/viper" "golang.org/x/term" @@ -292,7 +291,6 @@ func executeCLI(cmd *cobra.Command, src *source, w io.Writer) error { // initialize glamour r, err := glamour.NewTermRenderer( - glamour.WithColorProfile(termenv.ColorProfile()), utils.GlamourStyle(style, isCode), glamour.WithWordWrap(int(width)), //nolint:gosec glamour.WithBaseURL(baseURL), @@ -402,7 +400,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&configFile, "config", "", fmt.Sprintf("config file (default %s)", viper.GetViper().ConfigFileUsed())) rootCmd.Flags().BoolVarP(&pager, "pager", "p", false, "display with pager") rootCmd.Flags().BoolVarP(&tui, "tui", "t", false, "display with tui") - rootCmd.Flags().StringVarP(&style, "style", "s", styles.AutoStyle, "style name or JSON path") + rootCmd.Flags().StringVarP(&style, "style", "s", "auto", "style name or JSON path") rootCmd.Flags().UintVarP(&width, "width", "w", 0, "word-wrap at width (set to 0 to disable)") rootCmd.Flags().BoolVarP(&showAllFiles, "all", "a", false, "show system files and directories (TUI-mode only)") rootCmd.Flags().BoolVarP(&showLineNumbers, "line-numbers", "l", false, "show line numbers (TUI-mode only)") @@ -421,7 +419,7 @@ func init() { _ = viper.BindPFlag("showLineNumbers", rootCmd.Flags().Lookup("line-numbers")) _ = viper.BindPFlag("all", rootCmd.Flags().Lookup("all")) - viper.SetDefault("style", styles.AutoStyle) + viper.SetDefault("style", "auto") viper.SetDefault("width", 0) viper.SetDefault("all", true) diff --git a/ui/pager.go b/ui/pager.go index d7b6590..bec1412 100644 --- a/ui/pager.go +++ b/ui/pager.go @@ -11,7 +11,7 @@ import ( tea "charm.land/bubbletea/v2" "charm.land/lipgloss/v2" "github.com/atotto/clipboard" - "github.com/charmbracelet/glamour" + "charm.land/glamour/v2" "github.com/charmbracelet/glow/v2/utils" "github.com/charmbracelet/log" "github.com/fsnotify/fsnotify" diff --git a/ui/ui.go b/ui/ui.go index 28b2b36..976b5c3 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -10,7 +10,7 @@ import ( tea "charm.land/bubbletea/v2" "charm.land/lipgloss/v2" - "github.com/charmbracelet/glamour/styles" + "charm.land/glamour/v2/styles" "github.com/charmbracelet/glow/v2/utils" "github.com/charmbracelet/log" "github.com/muesli/gitcha" @@ -124,7 +124,7 @@ func newModel(cfg Config, content string) tea.Model { initStyles() initSections() - if cfg.GlamourStyle == styles.AutoStyle { + if cfg.GlamourStyle == "auto" { if lipgloss.HasDarkBackground(os.Stdin, os.Stdout) { cfg.GlamourStyle = styles.DarkStyle } else { diff --git a/utils/utils.go b/utils/utils.go index 7341b55..5105a2f 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -8,9 +8,9 @@ import ( "strings" "charm.land/lipgloss/v2" - "github.com/charmbracelet/glamour" - "github.com/charmbracelet/glamour/ansi" - "github.com/charmbracelet/glamour/styles" + "charm.land/glamour/v2" + "charm.land/glamour/v2/ansi" + "charm.land/glamour/v2/styles" "github.com/mitchellh/go-homedir" ) @@ -72,8 +72,8 @@ func IsMarkdownFile(filename string) bool { // GlamourStyle returns a glamour.TermRendererOption based on the given style. func GlamourStyle(style string, isCode bool) glamour.TermRendererOption { if !isCode { - if style == styles.AutoStyle { - return glamour.WithAutoStyle() + if style == "auto" { + return glamour.WithStandardStyle("dark") } return glamour.WithStylePath(style) } @@ -84,7 +84,7 @@ func GlamourStyle(style string, isCode bool) glamour.TermRendererOption { var styleConfig ansi.StyleConfig switch style { - case styles.AutoStyle: + case "auto": if lipgloss.HasDarkBackground(os.Stdin, os.Stdout) { styleConfig = styles.DarkStyleConfig } else {