lsp

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SourceFormatAllTofu is a OpenTofu specific format code action.
	SourceFormatAllTofu = "source.formatAll.opentofu"
)

Variables

View Source
var (

	// `source.formatAll`: Generic format code action.
	// We do not register this for terraform to allow fine grained selection of actions.
	// A user should be able to set `source.formatAll` to true, and source.formatAll.opentofu to false to allow all
	// files to be formatted, but not terraform files (or vice versa).
	SupportedCodeActions = CodeActions{
		SourceFormatAllTofu: true,
	}
)

Functions

func ClientCapabilities

func ClientCapabilities(ctx context.Context) (lsp.ClientCapabilities, error)

func ClientName

func ClientName(ctx context.Context) (string, bool)

func Command

func Command(cmd lang.Command) (lsp.Command, error)

func ContextWithClientName

func ContextWithClientName(ctx context.Context, namePtr *string) context.Context

func DirHandleFromDirURI

func DirHandleFromDirURI(dirUri lsp.DocumentURI) document.DirHandle

func HCLDiagsToLSP

func HCLDiagsToLSP(hclDiags hcl.Diagnostics, source string) []lsp.Diagnostic

func HCLPosToLSP

func HCLPosToLSP(pos hcl.Pos) lsp.Position

func HCLPositionFromLspPosition

func HCLPositionFromLspPosition(pos lsp.Position, doc *document.Document) (hcl.Pos, error)

func HCLRangeToLSP

func HCLRangeToLSP(rng hcl.Range) lsp.Range

func HCLSeverityToLSP

func HCLSeverityToLSP(severity hcl.DiagnosticSeverity) lsp.DiagnosticSeverity

func HandleFromDocumentURI

func HandleFromDocumentURI(docUri lsp.DocumentURI) document.Handle

func IsValidConfigLanguage added in v0.1.0

func IsValidConfigLanguage(id string) bool

func IsValidVarsLanguage added in v0.1.0

func IsValidVarsLanguage(id string) bool

func RefOriginsToLocations

func RefOriginsToLocations(origins decoder.ReferenceOrigins) []lsp.Location
func RefTargetsToDeclarationLocationLinks(targets decoder.ReferenceTargets, declCaps *lsp.DeclarationClientCapabilities) interface{}
func RefTargetsToDefinitionLocationLinks(targets decoder.ReferenceTargets, defCaps *lsp.DefinitionClientCapabilities) interface{}
func RefTargetsToLocationLinks(targets decoder.ReferenceTargets, linkSupport bool) interface{}

func SetClientCapabilities

func SetClientCapabilities(ctx context.Context, caps *lsp.ClientCapabilities) error

func SetClientName

func SetClientName(ctx context.Context, name string) error

func TextEdits

func TextEdits(tes []lang.TextEdit, snippetSupport bool) []lsp.TextEdit

func TextEditsFromDocumentChanges

func TextEditsFromDocumentChanges(changes document.Changes) []lsp.TextEdit

func ToSignatureHelp

func ToSignatureHelp(signature *lang.FunctionSignature) *lsp.SignatureHelp

func TokenModifiersLegend

func TokenModifiersLegend(clientSupported []string) semtok.TokenModifiers

func TokenTypesLegend

func TokenTypesLegend(clientSupported []string) semtok.TokenTypes

func WithClientCapabilities

func WithClientCapabilities(ctx context.Context, caps *lsp.ClientCapabilities) context.Context

Types

type CodeActions

type CodeActions map[lsp.CodeActionKind]bool

func (CodeActions) AsSlice

func (c CodeActions) AsSlice() []lsp.CodeActionKind

func (CodeActions) Only

func (ca CodeActions) Only(only []lsp.CodeActionKind) CodeActions

type DirHandler

type DirHandler interface {
	Dir() string
	URI() string
}

type LanguageID

type LanguageID string

LanguageID represents the coding language of a file

const (
	OpenTofu     LanguageID = "opentofu"
	OpenTofuVars LanguageID = "opentofu-vars"
	// Terraform - Some editors do not support language ID overrides which makes it difficult to use this language server
	// We also need to accept language IDs of Terraform to circumvent this issue
	Terraform     LanguageID = "terraform"
	TerraformVars LanguageID = "terraform-vars"
)

func ParseLanguageID added in v0.1.0

func ParseLanguageID(id string) LanguageID

ParseLanguageID parses a string into a LanguageID We also remap Terraform to OpenTofu and TerraformVars to OpenTofuVars We assume that the language ID is valid or the validation step has been done before parsing

func (LanguageID) String

func (l LanguageID) String() string

type SemanticTokensClientCapabilities

type SemanticTokensClientCapabilities struct {
	lsp.SemanticTokensClientCapabilities
}

func (SemanticTokensClientCapabilities) FullRequest

func (c SemanticTokensClientCapabilities) FullRequest() bool

type TokenEncoder

type TokenEncoder struct {
	Lines      source.Lines
	Tokens     []lang.SemanticToken
	ClientCaps lsp.SemanticTokensClientCapabilities
	// contains filtered or unexported fields
}

func (*TokenEncoder) Encode

func (te *TokenEncoder) Encode() []uint32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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