Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

go-lsp

> 编程语言
Open source

Write Language Servers that comply with 3.17 of the LSP Specification

192 stars0 likes0 views
WebsiteGitHub

About

Write Language Servers that comply with 3.17 of the LSP Specification

go-lsp

go-lsp is a Go library for building Language Server Protocol servers in Go without reimplementing JSON-RPC transport, handler dispatch, document sync, or protocol types.

Why use go-lsp?

  • Typed LSP handlers instead of hand-rolled JSON-RPC plumbing
  • Auto-detected capabilities from the interfaces your handler implements
  • Built-in document store with full and incremental sync support
  • servertest harness for end-to-end LSP tests over in-memory pipes
  • Project scaffold generator to bootstrap a server quickly
  • Optional debug UI for inspecting live LSP traffic

Install

go get github.com/owenrumney/go-lsp

Minimal server

…

Implement server.HoverHandler, server.CompletionHandler, server.TextDocumentSyncHandler, and other interfaces as needed. go-lsp registers methods and advertises capabilities automatically.

Quick start

Generate a starter server:

go run github.com/owenrumney/go-lsp/cmd/scaffold@latest \
  --name mylang \
  --module github.com/you/mylang-lsp \
  --lang mylang \
  --features hover,completion,diagnostics

Run tests with the included harness:

func TestHover(t *testing.T) {
    h := servertest.New(t, &Handler{})

    h.DidOpen("file:///test.txt", "plaintext", "hello")
    hover, err := h.Hover("file:///test.txt", 0, 0)
    if err != nil {
        t.Fatal(err)
    }
    if hover == nil {
        t.Fatal("expected hover result")
    }
}

Feature highlights

Server-to-client APIs

server.Client includes helpers for common outbound LSP calls, including:

  • PublishDiagnostics
  • ShowMessage, LogMessage, ShowMessageRequest
  • ShowDocument
  • Configuration
  • ApplyEdit
  • RegisterCapability, UnregisterCapability
  • progress and refresh requests

Middleware and request controls

Server supports optional inbound middleware and request concurrency controls:

  • server.WithMethodMiddleware(...)
  • server.WithNotificationMiddleware(...)
  • server.WithMaxConcurrentRequests(n)
  • server.WithRequestTimeout(d)

These are opt-in. Default behavior stays simple.

Debug UI

The optional debug UI helps inspect LSP traffic while developing and testing.

Start here

  • Getting started: docs/getting-started.md
  • Testing guide: docs/testing.md
  • Examples: examples/
  • Package docs site: https://www.owenrumney.co.uk/go-lsp

Examples

  • examples/hover/ — basic hover provider
  • examples/completion/ — completion + resolve
  • examples/diagnostics/ — publish diagnostics on save
  • examples/codeactions/ — quick fixes and code actions
  • examples/symbols/ — document symbols
  • examples/toylang/ — multi-feature toy language server

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gogogolanglanguage-server-protocollsp

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言