decoder

package
v0.2.0-rc8 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package decoder supplies directory, file, and range level contexts for use by completion, hover, and other decoders.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetBehavior

func SetBehavior(b LangServerBehavior)

SetBehavior sets the singleton LangServerBehavior instance.

Types

type CompletionContext

type CompletionContext interface {
	Context
	// CompletionFunc returns a completion function for the supplied hook, if available or nil otherwise.
	CompletionFunc(hookName string) CompletionFunc
	// TargetSchema is the schema for references collected under a single attribute schema tree.
	TargetSchema() *schema.AttributeSchema
}

CompletionContext is the context used for completion and hover. In addition to the path context, it can provide a schema for all variables that are visible from a given position in a file.

type CompletionContextProvider

type CompletionContextProvider interface {
	ContextProvider
	PathCompletionContext(p lang.Path, file string, pos hcl.Pos) (CompletionContext, error)
}

CompletionContextProvider provides path and completion contexts.

type CompletionFunc

type CompletionFunc func(ctx CompletionFuncContext, matchPrefix string) ([]lang.HookCandidate, error)

CompletionFunc is the function signature for completion hooks.

type CompletionFuncContext

type CompletionFuncContext struct {
	PathContext Context // the path context.
	Dir         string  // the module directory.
	Filename    string  // the filename from where the hook was called.
	Pos         hcl.Pos // the position from where the hook was called.
}

CompletionFuncContext is the context passed to a completion hook.

type Context

type Context interface {
	schema.Lookup
	// Dir returns the directory path under which files are evaluated.
	Dir() string
	// Files is the list of filenames known at the current path.
	Files() []string
	// HCLFile returns the HCL file associated with the supplied expression.
	HCLFile(expr hcl.Expression) *hcl.File
	// FileBytes provides the bytes for the file associated with the supplied expression.
	FileBytes(e hcl.Expression) []byte
	// HCLFileByName returns the HCL file for the supplied name
	HCLFileByName(name string) (*hcl.File, bool)
	// FileBytesByName provides the bytes for the supplied file.
	FileBytesByName(name string) ([]byte, bool)
	// Behavior returns the language server behavior flags for the current session.
	Behavior() LangServerBehavior
}

Context is the context under which expressions are evaluated. It provides schema and file information for module files.

type ContextProvider

type ContextProvider interface {
	Paths() ([]lang.Path, error)              // the paths for which we have open files
	PathContext(p lang.Path) (Context, error) // the path context at a specific directory.
}

ContextProvider provides path contexts.

type LangServerBehavior

type LangServerBehavior struct {
	MaxCompletionItems         int  // max completion items to return (0 means use default of 100)
	IndentMultiLineProposals   bool // when true, add leading spaces to multiple proposals based on current indent
	InnerBraceRangesForFolding bool // when true, ensure that folding range is the range not including braces
}

LangServerBehavior contains flags that influence how the language server behaves based on calling client identity. A singleton instance is initialized during the LSP initialize call and made accessible to feature implementations via Context.

func GetBehavior

func GetBehavior() LangServerBehavior

GetBehavior returns the singleton LangServerBehavior instance.

Directories

Path Synopsis
Package completion provides facilities for auto-complete and hover information.
Package completion provides facilities for auto-complete and hover information.
Package folding provides folding range support for HCL files.
Package folding provides folding range support for HCL files.
Package symbols provides document symbols.
Package symbols provides document symbols.

Jump to

Keyboard shortcuts

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