Documentation
¶
Index ¶
Constants ¶
const ( DefaultTextWidth = 80 DefaultTabWidth = 4 DefaultMaxWrap = 20 DefaultMaxIndentRetain = 40 DefaultWrapIndicator = "\u21aa" // '↪' - rightwards arrow with hook )
const MinSoftWrapWidth = 10
Variables ¶
var ErrInvalidAutoPairConfig = errors.New("invalid auto-pair config")
Functions ¶
func DetectLanguage ¶
func DetectLanguage(args DetectLanguageArgs) string
DetectLanguage identifies a language from the file name, then its shebang, then its content, trying Chroma's lexers when no definition matches and returning Default when nothing does
Types ¶
type AutoPairConfig ¶
func (*AutoPairConfig) AutoPairs ¶
func (a *AutoPairConfig) AutoPairs() (core.AutoPairs, bool)
AutoPairs returns the configured pairs only
func (*AutoPairConfig) OrDefault ¶
func (a *AutoPairConfig) OrDefault() (core.AutoPairs, bool)
OrDefault returns the configured pairs, or the built-in set when unset
func (*AutoPairConfig) UnmarshalTOML ¶
func (a *AutoPairConfig) UnmarshalTOML(value any) error
UnmarshalTOML accepts either a bool or a table of pair characters
type DetectLanguageArgs ¶ added in v0.2.0
DetectLanguageArgs is a file path and its content, both used to identify the language, plus the name to fall back to when nothing matches
type Language ¶
type Language struct {
Name string `toml:"name"`
LanguageID string `toml:"language-id"`
InjectionRegex string `toml:"injection-regex"`
FileTypes []FileType
Shebangs []string `toml:"shebangs"`
Roots []string `toml:"roots"`
CommentTokens []string
BlockCommentTokens []core.BlockCommentToken
Indent Indent
AutoPairs AutoPairConfig
TextWidth *int `toml:"text-width"`
SoftWrap SoftWrap `toml:"soft-wrap"`
Rulers []int `toml:"rulers"`
LanguageServers []string
AutoFormat bool `toml:"auto-format"`
Formatter *Formatter
}
func ForFilename ¶ added in v0.1.21
ForFilename returns the configured language matching path
func LoadLanguage ¶
LoadLanguage returns the bundled definition for a language name
type Languages ¶
func LoadBundledLanguages ¶
LoadBundledLanguages returns the definitions embedded in the binary
func LoadLanguagesForWorkspace ¶
func LoadLanguagesForWorkspace(args loader.WorkspaceFiles) (Languages, bool)
LoadLanguagesForWorkspace merges bundled, user, and workspace definitions
type TextFormat ¶
type TextFormat struct {
ViewportWidth int
TabWidth int
SoftWrap bool
MaxWrap int
MaxIndentRetain int
WrapIndicator string
SoftWrapAtTextWidth bool
}
func DefaultTextFormat ¶
func DefaultTextFormat(w int) *TextFormat
DefaultTextFormat builds the render format used when no language matches
func TextFormatForConfig ¶
func TextFormatForConfig( lang *Language, textWidth *int, softWrap SoftWrap, w int, ) *TextFormat
TextFormatForConfig builds the render format for a language and width
func (*TextFormat) WrapIndicatorPrefix ¶ added in v0.1.19
func (t *TextFormat) WrapIndicatorPrefix() string
WrapIndicatorPrefix is the indicator plus its gap, as drawn at the start of a soft-wrapped continuation row