langserver
A small, language-agnostic adapter for building language servers in Go.
It handles the parts every language server repeats, namely JSON-RPC framing, sessions and LSP position mapping, and knows nothing about any particular language. You supply functions; it supplies the protocol.
handlers := map[string]langserver.Handler{
"textDocument/completion": func(s langserver.Session, params json.RawMessage) (any, *langserver.RPCError) {
// call your language's completion function
},
}Install01
go get github.com/xraph/langserverPackages02
| Package | Purpose | Dependencies |
langserver | JSON-RPC framing, sessions, handler dispatch | none |
langserver/lsp | LSP positions and ranges | none |
langserver/stdio | stdio binding, how editors launch a server | none |
langserver/ws | WebSocket binding | gorilla/websocket |
Note
A language module can depend on the core packages to ship an LSP binary without inheriting a WebSocket stack. That is enforced by a test, not by a convention nobody checks.
Who uses it03
DQL ships dql-lsp on this adapter. Anything with functions to
call can do the same.