lsp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lsp is the stdio language server behind `wtctl lsp` (LSP 3.17): production latency and error lenses and hovers on functions. It sends only file paths and function names to the API, never source text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL string // WT_API_URL
	Key     string // WT_API_KEY
	HTTP    *http.Client
}

Client calls the Watchtower API. It sends only the service, file path and function names.

func (*Client) CodeStats

func (c *Client) CodeStats(ctx context.Context, project, service, file string, funcs []string) (map[string]Stat, error)

CodeStats returns stats by function name; functions with no data are absent.

type Config

type Config struct {
	Service      string   `yaml:"service"`
	PathPrefixes []string `yaml:"path_prefixes"`
	Project      string   `yaml:"project"`
}

Config is watchtower.yaml in the repository root.

func LoadConfig

func LoadConfig(root string) (*Config, error)

LoadConfig reads root/watchtower.yaml. A missing file is not an error: nothing maps.

func (*Config) ServiceFor

func (c *Config) ServiceFor(rel string) (string, bool)

ServiceFor returns the service for a repo-relative path. No prefixes means the whole repo.

type Func

type Func struct {
	Name string
	Line int
}

Func is a function declaration found in source (0-based line).

func Functions

func Functions(name, text string) []Func

Functions lists function names with their lines for the file extension of name.

type Server

type Server struct {
	API    *Client
	WebURL string // base of issue and trace links; defaults to the API URL
	// contains filtered or unexported fields
}

Server is one LSP session.

func NewServer

func NewServer(api *Client, webURL string, out io.Writer) *Server

NewServer builds a server writing responses to out.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, in io.Reader) error

Serve reads framed messages from in until exit or EOF.

type Stat

type Stat struct {
	Function  string  `json:"function"`
	Count     uint64  `json:"count"`
	Errors    uint64  `json:"errors"`
	P50Ms     float64 `json:"p50_ms"`
	P95Ms     float64 `json:"p95_ms"`
	LastIssue *struct {
		ID    string `json:"id"`
		Title string `json:"title"`
	} `json:"last_issue"`
	TraceExample string `json:"trace_example"`
}

Stat mirrors one entry of GET /v1/projects/{p}/code-stats.

Jump to

Keyboard shortcuts

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