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 ¶
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 ¶
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.
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 ¶
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.