Documentation
¶
Overview ¶
Package highlight implements syntax highlighting.
Uses the chroma lexer to automatically select the appropriate lexer based on file extension, tokenizing text and mapping tokens to terminal colors.
Design: The chroma library provides lexing and styling. We create our own style (easyedit style), mapped to tcell colors. Tokenized results are cached and only re-parsed when the document changes.
Supported file types: - .py Python - .js / .jsx / .mjs JavaScript - .ts / .tsx TypeScript - .json JSON - .sh / .bash Shell - .html / .htm HTML - .css CSS - .md / .markdown Markdown - .go Go - .rs Rust - .yaml / .yml YAML - .java Java - .c / .h C - .cpp / .hpp / .cc C++ - .rb Ruby - .vix / .vixl Vix-lang
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchingBracket ¶
MatchingBracket returns the matching bracket for a given bracket rune.
Types ¶
type Highlighter ¶
type Highlighter struct {
// contains filtered or unexported fields
}
Highlighter manages syntax highlighting.
func NewHighlighter ¶
func NewHighlighter(filePath string) *Highlighter
NewHighlighter creates a highlighter based on file path.
func (*Highlighter) GetTokenStyle ¶
func (h *Highlighter) GetTokenStyle(t chroma.TokenType) TokenStyle
GetTokenStyle maps a chroma token type to terminal colors. Uses the monokai theme style mapping.
func (*Highlighter) SetFile ¶
func (h *Highlighter) SetFile(filePath string)
SetFile updates the lexer when switching files.