Documentation
¶
Overview ¶
Package runtime discovers the JavaScript toolchain installed on the host and provisions npm-distributed language servers on demand.
Pando prefers bun over Node.js, unless the LSPRunner setting pins a specific package manager. When no usable toolchain remains, no npm package can be installed or executed, and callers must fall back to whatever binary is already on PATH (or tell the user how to install it).
Index ¶
Constants ¶
const DefaultInstallTimeout = 300 * time.Second
DefaultInstallTimeout caps a single package installation. Cold npm installs of heavy servers (typescript-language-server pulls the whole TypeScript compiler) routinely take a minute on a slow link.
Variables ¶
var ErrNoRuntime = errors.New("no JavaScript runtime found (install bun or node)")
ErrNoRuntime is returned when neither bun nor Node.js is installed, so no npm-distributed language server can be provisioned.
Functions ¶
func BinDir ¶
func BinDir() string
BinDir is the directory where staged server binaries are linked, so users can add a single directory to PATH to reuse them outside Pando.
func RootDir ¶
func RootDir() string
RootDir is the directory holding every language server Pando installed.
func SetForTests ¶
func SetForTests(rt NodeRuntime) func()
SetForTests pins the detected runtime, so tests in other packages do not depend on what is installed on the machine running them. It returns a function that restores the previous state, following config.SetForTests.
Types ¶
type Manager ¶
type Manager string
Manager identifies the package manager used to install and run npm packages.
type NodeRuntime ¶
type NodeRuntime struct {
// Manager is the package manager family that was detected.
Manager Manager
// Install is the absolute path of the binary that installs packages into a
// staging directory ("bun" or "npm"). Empty when only an ephemeral runner
// is available.
Install string
// Exec is the absolute path of the binary that runs a package without
// installing it ("bunx" or "npx"). Empty when only the installer is
// available.
Exec string
// ExecArgs are the fixed arguments Exec needs before anything else. It is
// ["x"] when bunx is missing and `bun x` is used instead.
ExecArgs []string
}
NodeRuntime describes the JavaScript toolchain available on the host.
func Detect ¶
func Detect() NodeRuntime
Detect returns the JavaScript toolchain Pando should use, honoring the LSPRunner setting. PATH is probed once per process — it is not expected to change while Pando runs, and this is called on every on-demand activation — but the preference is re-read on every call.
func DetectFor ¶
func DetectFor(preference string) NodeRuntime
DetectFor returns the toolchain for an explicit runner preference ("auto", "bun", "npm" or "off"), regardless of the current configuration.
func (NodeRuntime) Available ¶
func (r NodeRuntime) Available() bool
Available reports whether any npm package can be provisioned at all.
type Package ¶
type Package struct {
// Spec is the npm package to install, optionally versioned:
// "pyright", "@vue/language-server", "intelephense@1.10.0".
Spec string
// Bin is the executable the package exposes in node_modules/.bin. It is
// often different from the package name (pyright -> pyright-langserver).
Bin string
// Extra lists additional packages that must be installed alongside Spec.
// These are peer dependencies the package manager will not pull on its own,
// e.g. "typescript" for typescript-language-server.
Extra []string
}
Package describes an npm-distributed language server.
type Result ¶
type Result struct {
// Command is the executable to spawn.
Command string
// Args are the arguments that must precede the server's own arguments.
Args []string
// Installed is true when Command points at a binary staged by Pando, and
// false when the server runs through an ephemeral runner (bunx/npx), which
// re-resolves the package on every start.
Installed bool
}
Result reports how a language server binary was resolved.
func Ensure ¶
Ensure resolves an executable for the package, installing it when needed.
Resolution order: an already-staged binary, then an install into Pando's staging directory, then an ephemeral runner (bunx/npx). It never returns a command that is known not to exist, so callers can spawn the result directly.