Documentation
¶
Overview ¶
Package options is the configuration layer of thrift-ls. It owns a partial-options model (Patch): every field is optional so configuration sources can be layered — defaults, a JSON config file, CLI flags, and LSP workspace settings — each overriding the previous.
The config file is thrift-ls.json, discovered by walking up from the file being formatted, like Biome's config discovery. THRIFT_LS_CONFIG overrides the search with an explicit path.
Index ¶
Constants ¶
const ConfigFileName = "thrift-ls.json"
ConfigFileName is the JSON config file name.
Variables ¶
This section is empty.
Functions ¶
func FindConfig ¶
FindConfig returns the config file path for dir: THRIFT_LS_CONFIG when set, otherwise the nearest thrift-ls.json walking up from dir. It returns an empty path when no config exists.
Types ¶
type Break ¶
type Break = formatter.PerConstruct[*bool]
Break configures layouts that are forced multiline per construct. A nil value is unset.
type Indent ¶
type Indent struct {
Value string // the indentation string, spaces or tabs
Width int // display width of one level
}
Indent is a resolved indentation: the string emitted for one level and its display width. It is set from a literal string of spaces or tabs.
func ParseIndentValue ¶
ParseIndentValue resolves a literal indent string:
" " literal spaces, used as written "\t" literal tabs, used as written
An empty spec yields the default of four spaces.
func (*Indent) UnmarshalJSON ¶
UnmarshalJSON accepts a literal string of spaces or tabs.
type Patch ¶
type Patch struct {
PrintWidth *int `json:"printWidth"`
Indent *Indent `json:"indent"`
TabWidth *int `json:"tabWidth"`
Align *string `json:"align"`
Separators *Separators `json:"separators"`
Break *Break `json:"break"`
IncludePaths *[]string `json:"includePaths"`
LogLevel *int `json:"logLevel"`
}
Patch is a partial set of options; nil fields are unset.
func Effective ¶
Effective returns the effective options for a file: defaults with the config patch applied. cfg may be nil.
func Load ¶
Load reads and parses a config file. Unknown keys are rejected so that typos and stale settings (e.g. the removed overrides feature) fail loudly.
func Parse ¶
Parse reads and parses a config document. Unknown keys are rejected so that typos and stale settings (e.g. the removed overrides feature) fail loudly. Include paths in the document are left as written; Load resolves them against the config file's directory.
func (Patch) Apply ¶
Apply overlays p onto base: every set field of p replaces the corresponding field of base.
type Separators ¶
type Separators = formatter.PerConstruct[*string]
Separators configures trailing separators per construct. A nil value is unset. It is an alias of the formatter's per-construct container, so adding a construct adds the config key, CLI flags, and validation in one place.