format

package
v0.5.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 9 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

Overview

Formatter service

Built-in formatter registry

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandRunner

type CommandRunner func(context.Context, []string, string, map[string]string) (int, error)

type Configuration

type Configuration struct {
	// Enabled=false (no formatter config) disables every formatter.
	Enabled   bool
	Overrides []FormatterOverride
}

type Context

type Context struct {
	Directory string
	Worktree  string
}

type Dependencies

type Dependencies struct {
	Which             func(string) (string, bool)
	NpmWhich          func(context.Context, string) (string, bool)
	ExperimentalOxfmt bool
}

Dependencies isolates PATH, npm, filesystem, flags, and process probes.

type EnabledFunc

type EnabledFunc func(context.Context, Context) ([]string, bool, error)

type FormatterOverride

type FormatterOverride struct {
	Key         string
	Disabled    bool
	Extensions  *[]string
	Command     *[]string
	Environment map[string]string
}

type Info

type Info struct {
	Key         string
	Name        string
	Environment map[string]string
	Extensions  []string
	Enabled     EnabledFunc
}

func Builtins

func Builtins(dependencies Dependencies) []Info

Builtins returns the built-in formatters. Every entry's Key, which is what a config override names, is also its Name, which is what it registers under, so an override reaches the formatter it names. The order is the order a file's candidates are collected in.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(instance Context, configuration Configuration, dependencies Dependencies, runner CommandRunner) *Service

func (*Service) File

func (s *Service) File(ctx context.Context, path string) (bool, error)

func (*Service) Status

func (s *Service) Status(ctx context.Context) ([]Status, error)

type Status

type Status struct {
	Name       string   `json:"name"`
	Extensions []string `json:"extensions"`
	Enabled    bool     `json:"enabled"`
}

Jump to

Keyboard shortcuts

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