lsp

package
v0.0.364 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

README

Ns LSP

ns lsp command implements language server protocol. It uses stdin/stdout as JSON-RPC2 medium.

The LSP can be used by various editors and IDEs. Notably fn-vscode extension plumbs this LSP into VSCode.

The LSP is implemented inside the ns binary to make sure that it editor integrations behave 100% consistent with the command line tools.

References

Examples

Documentation

Overview

Runs a Language Server Protocol (LSP) server ready to comminicate with any editor/IDE.

This command is not intended to be invoked by end-users directly. Instead respective editor plugins will manage the instances of LSP server as needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLSPCmd

func NewLSPCmd() *cobra.Command

func WriteOverlay

func WriteOverlay(underlying fs.ReadDirFS) *writeOverlay

Types

type FnWorkspace

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

Represents an Fn workspace with its partially-parsed Cue files. An Fn workspace is rooted in a directory with a `workspace.ns.textpb“ file. There may be multiple FnWorkspace's in an editor workspace. Roughly corresponds to a parsing.Root, schema.Workspace and [loader.PackageLoader].

func (*FnWorkspace) AbsPathForPkgName

func (ws *FnWorkspace) AbsPathForPkgName(ctx context.Context, pkgName string) (string, error)

Real filesystem path for the package name (example.com/module/package/file.cue). Supports external modules and may download them on-demand (hence [ctx]).

func (*FnWorkspace) AbsRoot

func (ws *FnWorkspace) AbsRoot() string

func (*FnWorkspace) EvalPackage

func (ws *FnWorkspace) EvalPackage(ctx context.Context, pkgName string) (cue.Value, error)

func (*FnWorkspace) FS

func (ws *FnWorkspace) FS() fs.ReadDirFS

func (*FnWorkspace) PkgNameInMainModule

func (ws *FnWorkspace) PkgNameInMainModule(relPath string) string

Take a relative path (package/file.cue) and returns a fully-qualified package name (example.com/module/package/file.cue) within the main workspace module.

func (*FnWorkspace) SnapshotDir

func (ws *FnWorkspace) SnapshotDir(ctx context.Context, pkgname schema.PackageName, opts memfs.SnapshotOpts) (*fncue.PackageContents, error)

type OpenFiles

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

Implements LSP document sync protocol to maintain a view into currently open files. For the open files the authoritative content is stored in the editor memory instead of the filesystem. TODO: Implement delta sync.

func NewOpenFiles

func NewOpenFiles() *OpenFiles

func (*OpenFiles) DidChange

func (of *OpenFiles) DidChange(params *protocol.DidChangeTextDocumentParams) (err error)

func (*OpenFiles) DidClose

func (of *OpenFiles) DidClose(params *protocol.DidCloseTextDocumentParams) (err error)

func (*OpenFiles) DidOpen

func (of *OpenFiles) DidOpen(params *protocol.DidOpenTextDocumentParams) (err error)

func (*OpenFiles) Read

func (of *OpenFiles) Read(uri protocol.URI) (Snapshot, error)

type Snapshot

type Snapshot struct {
	Version int32
	Text    string
}

Jump to

Keyboard shortcuts

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