Documentation
¶
Overview ¶
Package lsp runs language servers (gopls, typescript-language-server, pyright or pylsp, rust-analyzer) for the agent: the errors an edit leaves, in the edited files and in the files that use them, and the `lsp` tool's code navigation.
Index ¶
Constants ¶
const ToolName = "lsp"
ToolName is the code navigation tool.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Disabled bool `json:"disabled,omitempty"`
Servers map[string][]string `json:"servers,omitempty"`
}
Config is setup.json's `diagnostics.lsp`: Disabled turns every language server off; Servers replaces the command of a language (an argv such as ["pylsp"]), and an empty one turns that language off.
type Diagnostic ¶
type FileErrors ¶
type FileErrors struct {
Path string
Errors []Diagnostic
}
FileErrors are the errors of one file.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager starts one server per language and project root on first use and stops it when idle and on Close.
func NewManager ¶
NewManager returns a manager whose servers log stderr into logDir and run with env (nil for the daemon's environment) and the settings of config.
func (*Manager) Available ¶
Available reports whether a server would serve a project in dir, so the `lsp` tool is offered there.
func (*Manager) Close ¶
func (m *Manager) Close()
Close stops every server; the daemon calls it on shutdown.
func (*Manager) Diagnose ¶
Diagnose sends the edited files to their servers and waits for their diagnostics. A file whose server is missing, not ready within documentWait or silent about it is left out of Checked, so another check can take it. The errors in other files are all a server knows when it can tell that it diagnosed everything the edit affects (gopls), else those it published while it checked the edited files.
type Report ¶
type Report struct {
Checked []string
Errors map[string][]Diagnostic
Others []FileErrors
}
Report is what the language servers said after an edit: the edited files they checked and the errors in them, and the other files their servers know errors in, most recently published first.
func (Report) OtherLines ¶
OtherLines renders the errors of at most maxOtherFiles other files under a heading; nil when there are none.