Documentation
¶
Overview ¶
Package lsp implements a Language Server Protocol server for workflow configuration files, providing completions, diagnostics, and hover info.
Index ¶
- Variables
- func Completions(reg *Registry, doc *Document, ctx PositionContext) []protocol.CompletionItem
- func Diagnostics(reg *Registry, doc *Document) []protocol.Diagnostic
- func Hover(reg *Registry, _ *Document, ctx PositionContext) *protocol.Hover
- type Document
- type DocumentStore
- type ModuleTypeInfo
- type PositionContext
- type Registry
- type SectionKind
- type Server
- type StepTypeInfo
- type TriggerTypeInfo
Constants ¶
This section is empty.
Variables ¶
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.
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.
type StepTypeInfo ¶
StepTypeInfo holds metadata about a known step type for the LSP.
type TriggerTypeInfo ¶
TriggerTypeInfo holds metadata about a known trigger type.