lsp

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 9 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, _ *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 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 PositionContext

type PositionContext struct {
	Section    SectionKind
	ModuleType string // if inside a modules[] item config, the type value
	FieldName  string // the field name at the cursor
	InTemplate bool   // cursor is inside {{ }}
	DependsOn  bool   // cursor is in a dependsOn array value
	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() *Server

NewServer creates a new LSP server with all handlers registered.

func (*Server) RunStdio

func (s *Server) RunStdio() error

RunStdio starts the LSP server over stdio (blocking).

type StepTypeInfo

type StepTypeInfo struct {
	Type        string
	Description string
	ConfigKeys  []string
}

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

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