gum: `gum format` does not syntax highlight code

Is your feature request related to a problem? Please describe. I’ve saved valid javascript and go code in files with their respective extensions, and after cat <file> | gum format -t code it spits out the code, but all in grey, not with proper syntax highlight as expected.

Describe the solution you’d like Syntax-highlighted code is the expected outcome, either by using chroma’s

lexer := lexers.Analyse("package main\n\nfunc main()\n{\n}\n")

or by passing in a language as a flag in a way chroma expects, like

cat file.go | gum format -t code -l go

Describe alternatives you’ve considered

Alternatively, it could also take in a filepath (not contents), although that would make it more confusing:

format -t code -f ./some/file/path.go

Additional context the format README says that it is using Glamour, and Glamour is using Chroma, however Glamour is only using Chroma when specifying code blocks, which Gum is not specifying language.

I’m new to Go, and unsure where to start (can read, not yet write 😅), but this issue should provide enough linkylinks for someone with more Go-fu than I to implement a language feature!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17 (6 by maintainers)

Most upvoted comments

It appears as though sometimes the language autodetection doesn’t work, I’ve added #323 to allow specifying the language so that highlighting appears correctly.

image

Awesome, thank you!

I also do not see syntax highlighting whether I run format type code or markdown (I’ve tried both Go and Python), would definitely like to know a fix or workaround for this.