lsp

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 12 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 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 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 {{ }}
	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
	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
}

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