Help us shape the future of Go! Take the 2026 Go Developer Survey

lsp

package
v0.87.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package lsp implements a Language Server Protocol server for workflow configuration files, providing completions, diagnostics, and hover info.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is set at build time.

Functions

func Completions

func Completions(reg *Registry, doc *Document, ctx PositionContext) []protocol.CompletionItem

Completions returns completion items for the given document and position context.

func Diagnostics

func Diagnostics(reg *Registry, doc *Document) []protocol.Diagnostic

Diagnostics analyses a document and returns LSP diagnostics.

func Hover

func Hover(reg *Registry, doc *Document, ctx PositionContext) *protocol.Hover

Hover returns markdown hover content for the given position context, or nil if there is nothing to show.

Types

type CompletionResult added in v0.10.1

type CompletionResult struct {
	Label  string `json:"label"`
	Kind   string `json:"kind,omitempty"`
	Detail string `json:"detail,omitempty"`
}

CompletionResult is a single completion item returned by CompleteAt.

func CompleteAt added in v0.10.1

func CompleteAt(content string, line, col int, pluginDir ...string) []CompletionResult

CompleteAt returns completion suggestions for the given content at (line, col). Both line and col are zero-based. An optional pluginDir can be provided.

type DSLSectionDoc added in v0.3.69

type DSLSectionDoc struct {
	ID          string
	Title       string
	Description string
	Example     string
}

DSLSectionDoc holds abbreviated documentation for one DSL section, used for hover.

type DiagSeverity added in v0.10.1

type DiagSeverity int

DiagSeverity is the severity level of a diagnostic message.

const (
	// SeverityError indicates a hard error that prevents correct operation.
	SeverityError DiagSeverity = 1
	// SeverityWarning indicates a potential issue.
	SeverityWarning DiagSeverity = 2
	// SeverityInformation indicates an informational message.
	SeverityInformation DiagSeverity = 3
	// SeverityHint indicates a hint or suggestion.
	SeverityHint DiagSeverity = 4
)

type Diagnostic added in v0.10.1

type Diagnostic struct {
	Line     int          `json:"line"`
	Col      int          `json:"col"`
	EndLine  int          `json:"end_line"`
	EndCol   int          `json:"end_col"`
	Message  string       `json:"message"`
	Severity DiagSeverity `json:"severity"`
	Source   string       `json:"source,omitempty"`
}

Diagnostic is a language-server-style diagnostic returned by DiagnoseContent.

func DiagnoseContent added in v0.10.1

func DiagnoseContent(content string, pluginDir ...string) []Diagnostic

DiagnoseContent analyses YAML content in-process and returns diagnostics without requiring an LSP client connection. An optional pluginDir can be provided to load step schemas from external plugin manifests.

type Document

type Document struct {
	URI     string
	Content string
	Node    *yaml.Node // root node (Kind == DocumentNode)
}

Document holds the content and parsed state of an open YAML file.

type DocumentStore

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

DocumentStore is a thread-safe store of open LSP documents.

func NewDocumentStore

func NewDocumentStore() *DocumentStore

NewDocumentStore creates an empty DocumentStore.

func (*DocumentStore) Delete

func (ds *DocumentStore) Delete(uri string)

Delete removes a document from the store.

func (*DocumentStore) Get

func (ds *DocumentStore) Get(uri string) *Document

Get returns a document by URI, or nil if not found.

func (*DocumentStore) Set

func (ds *DocumentStore) Set(uri, content string) *Document

Set stores or replaces a document.

type FieldSchema added in v0.3.20

type FieldSchema struct {
	Name        string         `json:"name"`
	Type        string         `json:"type"`
	Format      string         `json:"format,omitempty"`
	Description string         `json:"description,omitempty"`
	Required    bool           `json:"required,omitempty"`
	Children    []*FieldSchema `json:"children,omitempty"`
}

FieldSchema describes a single data field with rich metadata.

type HoverResult added in v0.10.1

type HoverResult struct {
	Content string `json:"content"`
}

HoverResult is the hover content returned by HoverAt.

func HoverAt added in v0.10.1

func HoverAt(content string, line, col int, pluginDir ...string) *HoverResult

HoverAt returns hover documentation for the given content at (line, col). Both line and col are zero-based. Returns nil if there is no hover info. An optional pluginDir can be provided.

type ModuleTypeInfo

type ModuleTypeInfo struct {
	Type        string
	Label       string
	Category    string
	Description string
	ConfigKeys  []string
}

ModuleTypeInfo holds metadata about a known module type for the LSP.

type PipelineDataContext added in v0.3.20

type PipelineDataContext struct {
	PipelineName string                       `json:"pipelineName"`
	StepOrder    []string                     `json:"stepOrder"`
	Steps        map[string]*StepOutputSchema `json:"steps"`
	Trigger      *TriggerSchema               `json:"trigger,omitempty"`
}

PipelineDataContext is the full set of context keys available at a given cursor position in a pipeline, combining trigger data with step outputs accumulated from all steps preceding the cursor.

func BuildPipelineContext added in v0.3.20

func BuildPipelineContext(reg *Registry, doc *Document, cursorLine int) *PipelineDataContext

BuildPipelineContext builds a PipelineDataContext for the pipeline that contains cursorLine (0-based). It uses yaml.Node.Line (1-based) internally to locate the pipeline and identify which steps precede the cursor.

OpenAPI trigger schema is auto-discovered from a module with type containing "openapi" and a config.spec_file key. Method and path are read from the pipeline's own trigger: section. Falls back to a generic {type: "http"} trigger when no OpenAPI spec is found or matched.

type PositionContext

type PositionContext struct {
	Section         SectionKind
	ModuleType      string            // if inside a modules[] item config, the type value
	StepType        string            // if inside a pipeline step config, the step type value
	FieldName       string            // the field name at the cursor
	InTemplate      bool              // cursor is inside {{ }}
	InExpr          bool              // cursor is inside ${ }
	DependsOn       bool              // cursor is in a dependsOn array value
	PipelineName    string            // name of the pipeline containing the cursor (if any)
	CurrentStepName string            // name of the step containing the cursor (if any)
	TemplatePath    *TemplateExprPath // parsed template expression at cursor, if InTemplate or InExpr
	Line            int
	Character       int
}

PositionContext describes what context the cursor is in within the document.

func ContextAt

func ContextAt(content string, line, char int) PositionContext

ContextAt analyses the document content at the given (zero-based) line and character position and returns a PositionContext describing what the cursor is positioned on.

type Registry

type Registry struct {
	ModuleTypes   map[string]ModuleTypeInfo
	StepTypes     map[string]StepTypeInfo
	TriggerTypes  map[string]TriggerTypeInfo
	WorkflowTypes []string
	DSLSections   map[string]*DSLSectionDoc // section ID → parsed doc from dsl-reference.md
}

Registry aggregates all known workflow types for LSP use.

func NewRegistry

func NewRegistry() *Registry

NewRegistry builds a Registry from the schema package's known types and registry.

type SectionKind

type SectionKind string

SectionKind identifies the YAML section the cursor is in.

const (
	SectionUnknown  SectionKind = "unknown"
	SectionModules  SectionKind = "modules"
	SectionWorkflow SectionKind = "workflows"
	SectionTriggers SectionKind = "triggers"
	SectionPipeline SectionKind = "pipelines"
	SectionRequires SectionKind = "requires"
	SectionImports  SectionKind = "imports"
	SectionTopLevel SectionKind = "top_level"
)

type Server

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

Server is the workflow LSP server.

func NewServer

func NewServer(pluginDir ...string) *Server

NewServer creates a new LSP server with all handlers registered. An optional pluginDir can be provided to load step schemas from external plugin manifests (plugin.json files).

func (*Server) RunStdio

func (s *Server) RunStdio() error

RunStdio starts the LSP server over stdio (blocking).

type StepOutputSchema added in v0.3.20

type StepOutputSchema struct {
	StepName string                  `json:"stepName"`
	StepType string                  `json:"stepType"`
	Fields   []schema.InferredOutput `json:"fields"`
}

StepOutputSchema holds the inferred outputs for a completed pipeline step.

type StepTypeInfo

type StepTypeInfo struct {
	Type        string
	Description string
	ConfigKeys  []string
	ConfigDefs  []schema.ConfigFieldDef // rich per-key metadata
	Outputs     []schema.StepOutputDef  // step output keys
}

StepTypeInfo holds metadata about a known step type for the LSP.

type TemplateExprPath added in v0.3.20

type TemplateExprPath struct {
	Namespace   string // "steps", "trigger", "meta", "body", or "" (top-level)
	StepName    string // if Namespace=="steps", the step name
	SubField    string // nested path within namespace (e.g. "path_params" for trigger, "address" for body)
	FieldPrefix string // partial field name being typed (for filtering)
	Raw         string // the raw expression text before cursor
}

TemplateExprPath represents the parsed cursor position within a template expression.

func ParseExprAt added in v0.5.0

func ParseExprAt(line string, char int) *TemplateExprPath

ParseExprAt parses the expr expression from a line up to the cursor position. Returns nil if the cursor is not inside a ${ } block. The returned TemplateExprPath uses the same fields as ParseTemplateExprAt but interprets expr syntax: `steps["name"]["field"]`, `body.field`, etc.

func ParseTemplateExprAt added in v0.3.20

func ParseTemplateExprAt(line string, char int) *TemplateExprPath

ParseTemplateExprAt extracts and parses the template expression from a line up to the cursor position. Returns nil if cursor is not in a template expression.

type TriggerSchema added in v0.3.20

type TriggerSchema struct {
	Type        string         `json:"type"`
	PathParams  []*FieldSchema `json:"pathParams,omitempty"`
	QueryParams []*FieldSchema `json:"queryParams,omitempty"`
	BodyFields  []*FieldSchema `json:"bodyFields,omitempty"`
	Headers     []*FieldSchema `json:"headers,omitempty"`
}

TriggerSchema describes the data surfaced by the workflow trigger.

type TriggerTypeInfo

type TriggerTypeInfo struct {
	Type        string
	Description string
}

TriggerTypeInfo holds metadata about a known trigger type.

Jump to

Keyboard shortcuts

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