Go primitives for practical LSP servers

go-lsp handles JSON-RPC framing, method dispatch, LSP protocol types, document state, testing, and debugging tools so your server code can focus on language behavior. It also ships a client for driving other language servers.

Install

go get github.com/owenrumney/go-lsp

Quick Server

type Handler struct{}

func (h *Handler) Initialize(context.Context, *lsp.InitializeParams) (*lsp.InitializeResult, error) {
    return &lsp.InitializeResult{
        ServerInfo: &lsp.ServerInfo{Name: "mylang", Version: "0.1.0"},
    }, nil
}

func (h *Handler) Shutdown(context.Context) error { return nil }

func main() {
    srv := server.NewServer(&Handler{})
    log.Fatal(srv.Run(context.Background(), server.RunStdio()))
}

What You Get

Interface-based handlers

Implement only the LSP features you need. The server registers methods and advertises capabilities automatically.

Document storage

document.Store applies full or incremental sync and handles UTF-16 LSP positions.

Test harness

servertest simulates an LSP client over in-memory pipes for focused handler tests.

LSP client

client drives another language server: spawn it, query it, and wait for it to finish indexing before trusting an empty result.

Debug traces

The debug UI captures live traffic, logs, timelines, and exportable traces for bug reports.