lsp

package
v0.2.0-rc7 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: 16 Imported by: 0

Documentation

Overview

Package lsp provides functions to convert generic interfaces to LSP-specific types.

This helps keeping individual packages independent of LSP types which effectively represent 3rd party dependency and centralizes all such conversion logic in one place.

It also enables consistency in how we convert data in both directions.

Index

Constants

View Source
const (
	// SourceFormatAllTerraform is a Terraform specific format code action.
	SourceFormatAllTerraform = "source.formatAll.terraform"
)

Variables

View Source
var SupportedCodeActions = CodeActions{
	SourceFormatAllTerraform: true,
}

`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.terraform to false to allow all files to be formatted, but not terraform files (or vice versa).

Functions

func Command

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

func FoldingRanges

func FoldingRanges(ranges []folding.Range) []lsp.FoldingRange

FoldingRanges converts internal folding ranges to LSP folding ranges. Input ranges use 1-based line/column (HCL convention). Output ranges use 0-based line/column (LSP convention).

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 TextEdits

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

func TextEditsFromDocumentChanges

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

func ToLocation

func ToLocation(path lang.Path, rng hcl.Range) lsp.Location
func ToLocationLink(path lang.Path, rng hcl.Range) lsp.LocationLink
func ToLocationLinks(path lang.Path, rng []hcl.Range) []lsp.LocationLink

func ToLocations

func ToLocations(path lang.Path, rng []hcl.Range) []lsp.Location

func ToSignatureHelp

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

func TokenModifiersLegend

func TokenModifiersLegend() semtok.TokenModifiers

func TokenTypesLegend

func TokenTypesLegend() semtok.TokenTypes

Types

type CodeActions

type CodeActions map[lsp.CodeActionKind]bool

func (CodeActions) AsSlice

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

func (CodeActions) Only

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

type LanguageID

type LanguageID string

LanguageID represents the coding language of a file

const (
	HCL LanguageID = "hcl"
)

func (LanguageID) String

func (l LanguageID) String() string

type TokenEncoder

type TokenEncoder struct {
	// contains filtered or unexported fields
}

func NewTokenEncoder

func NewTokenEncoder(tokens []semtok.SemanticToken, lines []source.Line) *TokenEncoder

func (*TokenEncoder) Encode

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

Jump to

Keyboard shortcuts

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