Documentation
¶
Overview ¶
Package highlight applies chroma syntax highlighting to diff content, picking a lexer from the file path. Highlighting is best effort: a path with no known lexer renders unstyled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Highlighter ¶
type Highlighter struct {
// contains filtered or unexported fields
}
Highlighter provides syntax highlighting for code.
func New ¶
func New() *Highlighter
New creates a syntax highlighter drawing in the process-wide theme.
func NewWith ¶ added in v0.3.0
func NewWith(p Palette) *Highlighter
NewWith creates a syntax highlighter drawing in p, for a caller outside this program that has its own palette and never calls theme.Init.
func (*Highlighter) HighlightLine ¶
func (h *Highlighter) HighlightLine(filePath, line string) string
HighlightLine applies syntax highlighting to a single line of code filePath is used to detect the language Returns the highlighted line with lipgloss styling.
func (*Highlighter) IsEnabled ¶
func (h *Highlighter) IsEnabled(filePath string) bool
IsEnabled returns whether syntax highlighting is available for a file.
type Palette ¶ added in v0.3.0
type Palette struct {
Comment color.Color
Keyword color.Color
String color.Color
Number color.Color
Name color.Color
Type color.Color
Operator color.Color
}
Palette is the face each token class renders in. A nil color leaves that class unstyled, which is what a caller with no color for it should pass rather than a guess.
func ThemePalette ¶ added in v0.3.0
func ThemePalette() Palette
ThemePalette is the palette built from the process-wide theme, which is what the diff editor itself renders with.