lsp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 26 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

Package lsp is apic's language server: `apic lsp` speaks the Language Server Protocol over stdio, so any editor with an LSP client gets the diagnostics, completion, hover, code lenses and formatting the VS Code extension has, from the same code the CLI runs.

The transport is JSON-RPC 2.0 with the protocol's Content-Length framing, written here in a couple of hundred lines rather than pulled in as a library, in the spirit of the SigV4 signer and the OpenAPI reader.

Index

Constants

View Source
const (
	CommandRun      = "apic.lsp.run"
	CommandDescribe = "apic.lsp.describe"
	CommandCurl     = "apic.lsp.curl"
	// CommandValidate checks every project of the workspace now and
	// answers once its diagnostics are published. It takes no arguments.
	CommandValidate = "apic.lsp.validate"
)

Command names the server executes through workspace/executeCommand, offered by its code lenses. The arguments are the document URI and the request's target (file#name or file#N, relative to the project root).

Variables

View Source
var ErrNoShutdown = errors.New("the client exited without a shutdown request")

ErrNoShutdown is what Serve returns when the client exits, or closes the stream, without a shutdown request first; the protocol asks the server to exit 1 then.

View Source
var Operators = []string{
	"==", "!=", "<", "<=", ">", ">=", "contains", "startsWith", "endsWith", "matches", "exists", "not exists",
	"isString", "isNumber", "isInteger", "isBoolean", "isArray", "isObject", "isNull", "isEmpty", "not isEmpty",
	"length ==", "matchesSchema",
}

Operators are the assertion operators, in the order the docs list them.

Functions

func Serve

func Serve(ctx context.Context, r io.Reader, w io.Writer, opts Options) error

Serve runs a language server on r and w until the client sends exit or closes the stream. It returns nil after a shutdown request and an exit notification, and ErrNoShutdown when the client goes without one.

Types

type Options

type Options struct {
	// Root is the project root to use when the client names no workspace
	// (`apic lsp -C dir`).
	Root string
	// Env is the environment hover, completion and the run command use;
	// the client's initializationOptions.env replaces it.
	Env string
	// Version is reported to the client in serverInfo.
	Version string
	// Debounce is how long the server waits after an edit before it checks
	// the project again, so a burst of keystrokes costs one check. Zero
	// checks after every edit. A request (completion, hover, a lens) for a
	// project with a check pending runs the check first.
	Debounce time.Duration
}

Options configures a server.

Jump to

Keyboard shortcuts

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