• Stars
    star
    160
  • Rank 234,703 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Language Server Protocol SDK for Go

This is an early release. Some features are not yet fully implemented.

GLSP

License Go Reference Go Report Card

Language Server Protocol SDK for Go.

It enables you to more easily implement language servers by writing them in Go. GLSP contains:

  1. all the message structures for easy serialization,
  2. a handler for all client methods, and
  3. a ready-to-run JSON-RPC 2.0 server supporting stdio, TCP, WebSockets, and Node.js IPC.

All you need to do, then, is provide the features for the language you want to support.

Projects using GLSP:

References

  • go-lsp is another implementation with reduced coverage of the protocol

Minimal Example

package main

import (
	"github.com/tliron/glsp"
	protocol "github.com/tliron/glsp/protocol_3_16"
	"github.com/tliron/glsp/server"
	"github.com/tliron/commonlog"

	// Must include a backend implementation
	// See CommonLog for other options: https://github.com/tliron/commonlog
	_ "github.com/tliron/commonlog/simple"
)

const lsName = "my language"

var (
	version string = "0.0.1"
	handler protocol.Handler
)

func main() {
	// This increases logging verbosity (optional)
	commonlog.Configure(1, nil)

	handler = protocol.Handler{
		Initialize:  initialize,
		Initialized: initialized,
		Shutdown:    shutdown,
		SetTrace:    setTrace,
	}

	server := server.NewServer(&handler, lsName, false)

	server.RunStdio()
}

func initialize(context *glsp.Context, params *protocol.InitializeParams) (any, error) {
	capabilities := handler.CreateServerCapabilities()

	return protocol.InitializeResult{
		Capabilities: capabilities,
		ServerInfo: &protocol.InitializeResultServerInfo{
			Name:    lsName,
			Version: &version,
		},
	}, nil
}

func initialized(context *glsp.Context, params *protocol.InitializedParams) error {
	return nil
}

func shutdown(context *glsp.Context) error {
	protocol.SetTraceValue(protocol.TraceValueOff)
	return nil
}

func setTrace(context *glsp.Context, params *protocol.SetTraceParams) error {
	protocol.SetTraceValue(params.Value)
	return nil
}

More Repositories

1

install-gnome-themes

Script to install the latest versions of some fine GNOME 3 themes
Shell
435
star
2

py4go

Tight bidirectional integration between Go and Python
Go
107
star
3

puccini

Cloud topology management and deployment tools based on TOSCA
Go
88
star
4

ronin

A straightforward but powerful build system based on Ninja and Python
Python
60
star
5

opengl-3d-vision-bridge

opengl-3d-vision-bridge
C
42
star
6

mongovision

Web frontend for MongoDB
JavaScript
39
star
7

turandot

Compose and orchestrate and Kubernetes workloads using TOSCA
Go
36
star
8

prudence

An opinionated lightweight web framework built for scale
HTML
13
star
9

pygobject-example

Create a library in either C or Vala and use it in Python
C
13
star
10

8812au

Linux driver for Realtek 802.11ac
C
12
star
11

khutulun

A distributed declarative orchestrator for services that speaks TOSCA
Go
12
star
12

open5gs-k8s

Open5GS on Kubernetes
C
11
star
13

knap

Kubernetes Network Attachment Provider
Go
11
star
14

jygments

Syntax highlighter (Pygments ported to Java)
Java
10
star
15

puccini-language-server

Language Server Protocol implementation for TOSCA
Go
8
star
16

em-dash

An enhanced GNOME Shell desktop dash
JavaScript
6
star
17

commonjs-goja

CommonJS support for Goja JavaScript engine for Go
Go
6
star
18

candice

Cloud-Native Network Device Configurator
Go
5
star
19

kutil

Go Utilities
Go
5
star
20

khovsgol

Shared music player and library/playlist manager
JavaScript
5
star
21

cnck

Cloud Native Configurations for Kubernetes
Go
5
star
22

planter

Meta-scheduler for Kubernetes
Go
5
star
23

mongodb-jvm

MongoDB integration with JVM language engines
JavaScript
5
star
24

vncj

VNC Server Toolkit for the JVM
Java
5
star
25

scripturian

Scalable alternative to JSR-223
Java
5
star
26

go-ard

Agnostic Raw Data for Go
Go
4
star
27

exceptional-c-exceptions

Exceptional C Exceptions
C
4
star
28

fedora-first

First steps after installing Fedora
Shell
4
star
29

yamlkeys

Support complex keys when decoding YAML in Go
Go
4
star
30

reposure

Manage and access cloud-native container image registries for Kubernetes
Go
4
star
31

klab

Various scripts for working with the Kubernetes ecosystem
Shell
4
star
32

puccini-terraform

Enable TOSCA for Terraform using Puccini
Go
3
star
33

puccini-web

Parse TOSCA in a browser using WebAssembly
Shell
3
star
34

kubernetes-registry-spooler

A sidecar to update an OCI/Docker container image registry using files instead of RESTful HTTP calls
Go
3
star
35

puccini-vscode

Visual Studio Code extension for TOSCA
TypeScript
3
star
36

python-ard

Agnostic Raw Data (ARD) for Python
Python
2
star
37

gamelauncher

Makes it easy to launch fullscreen games in a separate gaming desktop (GNOME/Ubuntu)
JavaScript
2
star
38

ardconv

Utility to convert between various ARD formats
Go
2
star
39

restlet-encoder-test

See: https://github.com/restlet/restlet-framework-java/issues/447
JavaScript
1
star
40

restlet-jetty9

Jetty 9 connector extension for Restlet 2.2
Java
1
star
41

restlet-async-test

Testing Restlet's asynchronous capabilities
Java
1
star
42

setup-puccini

GitHub action to setup Puccini in your runner
1
star
43

install-oracle-jdk

Straightforward shell script to install Oracle's JDK in Ubuntu
Shell
1
star
44

telephony-network-service

Shell
1
star
45

puccini-action-example

Example of using Puccini to validate TOSCA in a GitHub action
1
star
46

kind-multus-poc

Two KIND clusters communicating via Multus
Shell
1
star
47

qcr

Queued Custom Resources
1
star
48

json-jvm

High-performance JSON support for JVM language engines
Java
1
star
49

creel

Lightweight and lightning-fast library for resolving and downloading JVM dependencies from Maven repositories
Java
1
star
50

commonlog

A common Go API for structured and unstructured logging with support for pluggable backends and sinks
Go
1
star
51

diligence

Scalable web framework for Prudence and MongoDB
JavaScript
1
star
52

sincerity

Package manager for JVM containers
JavaScript
1
star