langregistry

package
v1.10.7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package langregistry provides an embedded language server registry with 40+ entries and YAML override support. It is the data layer consumed by the LS pool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlatformKey

func PlatformKey() string

PlatformKey returns the current platform key for binary downloads (e.g. "darwin-arm64").

Types

type InstallInfo

type InstallInfo struct {
	// Type is the installer type: "npm", "pip", "binary", "cargo", "gem", "dotnet", "system".
	Type string
	// Package is the package name (e.g. "pyright", "bash-language-server").
	Package string
	// Version is the pinned version string.
	Version string
	// URLs maps platform keys (e.g. "darwin-arm64") to download URLs for binary installs.
	URLs map[string]string
	// SHA256 maps platform keys to expected checksums for binary installs.
	SHA256 map[string]string
}

InstallInfo describes how to install a language server when it is not found in PATH.

type Installer

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

Installer resolves language server binaries using a three-tier strategy: 1. PATH lookup 2. Managed download (if AutoInstall and InstallInfo present) 3. Helpful error message

func NewInstaller

func NewInstaller(cfg InstallerConfig, logger *slog.Logger) *Installer

NewInstaller creates an Installer with the given configuration.

func (*Installer) Resolve

func (i *Installer) Resolve(ctx context.Context, entry LSEntry) (command string, args []string, err error)

Resolve finds or installs the language server for the given entry. It returns the resolved command path and arguments.

type InstallerConfig

type InstallerConfig struct {
	// AutoInstall enables managed download when a binary is not found in PATH.
	// Default: true.
	AutoInstall bool
	// BinDir is the directory for managed installs (default ~/.helix/bin/).
	BinDir string
}

InstallerConfig controls the three-tier LS resolution behavior.

type LSEntry

type LSEntry struct {
	// Language is the canonical language key (e.g. "go", "python").
	Language string
	// Command is the LS binary name (e.g. "gopls", "pyright-langserver").
	Command string
	// Args are the command-line arguments for the LS binary.
	Args []string
	// InitOptions are passed as initializationOptions in the LSP initialize request.
	InitOptions map[string]any
	// NeedsWorkspace indicates whether the LS requires workspace folders.
	NeedsWorkspace bool
	// FileExts lists file extensions associated with this language (e.g. [".go"]).
	FileExts []string
	// Install holds managed-install metadata. nil means system-only.
	Install *InstallInfo
	// IgnoredDirs lists directories to skip for this language.
	IgnoredDirs []string
}

LSEntry describes a language server binary, its arguments, file associations, and optional managed-install metadata.

func (LSEntry) InstallHint

func (e LSEntry) InstallHint() string

InstallHint returns a human-readable install instruction for this entry.

type Registry

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

Registry holds all language server entries with thread-safe access. It starts with compiled-in defaults and layers YAML overrides on top.

func NewRegistry

func NewRegistry(overridePaths ...string) (*Registry, error)

NewRegistry creates a Registry pre-loaded with defaultEntries and applies YAML overrides from the given file paths (in order, later overrides win). Override files that do not exist are silently skipped.

func (*Registry) ByExtension

func (r *Registry) ByExtension(ext string) []LSEntry

ByExtension returns all entries whose FileExts contain the given extension. The extension should include the dot (e.g. ".py").

func (*Registry) Entries

func (r *Registry) Entries() []LSEntry

Entries returns a copy of all registered entries sorted by language key.

func (*Registry) Get

func (r *Registry) Get(language string) (LSEntry, bool)

Get returns the LSEntry for the given language key.

func (*Registry) Languages

func (r *Registry) Languages() []string

Languages returns a sorted list of all registered language keys.

Jump to

Keyboard shortcuts

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