language

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultTextWidth       = 80
	DefaultTabWidth        = 4
	DefaultMaxWrap         = 20
	DefaultMaxIndentRetain = 40
	DefaultWrapIndicator   = "\u21aa " // '↪' - rightwards arrow with hook
)
View Source
const MinSoftWrapWidth = 10

Variables

View Source
var ErrInvalidAutoPairConfig = errors.New("invalid auto-pair config")

Functions

func DetectLanguage

func DetectLanguage(path, content string) (string, bool)

Types

type AutoPairConfig

type AutoPairConfig struct {
	Present bool
	Enable  *bool
	Pairs   [][2]rune
}

func (*AutoPairConfig) AutoPairs

func (a *AutoPairConfig) AutoPairs() (core.AutoPairs, bool)

func (*AutoPairConfig) OrDefault

func (a *AutoPairConfig) OrDefault() (core.AutoPairs, bool)

func (*AutoPairConfig) UnmarshalTOML

func (a *AutoPairConfig) UnmarshalTOML(value any) error

type FileType

type FileType struct {
	Extension string
	Glob      string
}

type Formatter

type Formatter struct {
	Command string
	Args    []string
}

type Grammar

type Grammar struct {
	Name   string
	Source GrammarSource
}

type GrammarSelection

type GrammarSelection struct {
	Only   []string
	Except []string
}

type GrammarSource

type GrammarSource struct {
	Path    string
	Git     string
	Rev     string
	Subpath string
}

type Indent

type Indent struct {
	TabWidth *int
	Unit     string
}

type Language

type Language struct {
	TextWidth          *int   `toml:"text-width"`
	Name               string `toml:"name"`
	LanguageID         string `toml:"language-id"`
	Scope              string `toml:"scope"`
	InjectionRegex     string `toml:"injection-regex"`
	FileTypes          []FileType
	Shebangs           []string `toml:"shebangs"`
	Roots              []string `toml:"roots"`
	LanguageServers    []ServerFeatures
	CommentTokens      []string
	BlockCommentTokens []core.BlockCommentToken
	Indent             Indent
	AutoPairs          AutoPairConfig
	AutoFormat         bool `toml:"auto-format"`
	Formatter          *Formatter
	SoftWrap           SoftWrap `toml:"soft-wrap"`
	Rulers             []int    `toml:"rulers"`
}

func LoadLanguage

func LoadLanguage(lang string) *Language

type Languages

type Languages struct {
	Languages        []Language
	LanguageServers  map[string]Server
	GrammarSelection GrammarSelection
	Grammars         []Grammar
}

func LoadBundledLanguages

func LoadBundledLanguages() (Languages, bool)

func LoadLanguagesForWorkspace

func LoadLanguagesForWorkspace(
	global, workspace, dir string,
) (Languages, bool)

type Server

type Server struct {
	Command              string
	Args                 []string
	Environment          map[string]string
	Config               map[string]any
	Timeout              int
	RequiredRootPatterns []string
}

type ServerFeatures

type ServerFeatures struct {
	Name string
}

type SoftWrap

type SoftWrap struct {
	Enable          *bool   `toml:"enable"`
	MaxWrap         *int    `toml:"max-wrap"`
	MaxIndentRetain *int    `toml:"max-indent-retain"`
	WrapIndicator   *string `toml:"wrap-indicator"`
	WrapAtTextWidth *bool   `toml:"wrap-at-text-width"`
}

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

func TextFormatForConfig

func TextFormatForConfig(
	lang *Language, textWidth *int, softWrap SoftWrap, w int,
) *TextFormat

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL