Home

Awesome

🚨 Note: this repo has been archived and its contents are now in the sourcegraph/sourcegraph repo.

Syntect Server

This is an HTTP server that exposes the Rust Syntect syntax highlighting library for use by other services. Send it some code, and it'll send you syntax-highlighted code in response.

Technologies:

Usage

docker run --detach --name=syntect_server -p 9238:9238 sourcegraph/syntect_server

You can then e.g. GET http://localhost:9238/health or http://host.docker.internal:9238/health to confirm it is working.

API

Client

gosyntect is a Go package + CLI program to make requests against syntect_server.

Configuration

By default on startup, syntect_server will list all features (themes + file types) it supports. This can be disabled by setting QUIET=true in the environment.

Development

  1. Install Rust nightly.
  2. git clone this repository anywhere on your filesystem.
  3. Use cargo run to download dependencies + compile + run the server.

Building

Invoke cargo build --release and an optimized binary will be built (e.g. to ./target/release/syntect_server).

Building docker image

./build.sh will build your current repository checkout into a final Docker image.

Publishing docker image

Run ./publish.sh after merging your changes.

Updating Sourcegraph

Once published, the image version will need to be updated in the following locations to make Sourcegraph use it:

Additionally, it's worth doing a search for other uses in case this list is stale.

Code hygiene

Adding themes

Adding languages:

1) Find an open-source .tmLanguage or .sublime-syntax file and send a PR to our package registry

https://github.com/slimsag/Packages is the package registry we use which holds all of the syntax definitions we use in syntect_server and Sourcegraph. Send a PR there by following these steps

2) Update our temporary fork of syntect

We use a temporary fork of syntect as a hack to get our Packages registry into the binary. Update it by creating a PR with two commits like:

3) Update syntect_server to use the new version of syntect

Send a PR to this repository with the result of running cargo update -p syntect.

4) Publish a new image, use it in Sourcegraph

Run ./publish.sh to build and release a new image of syntect_server, and then send a PR to the main Sourcegraph repository like this. Once merged, it will automatically rollout to Sourcegraph.com and go in the next Sourcegraph release.

Embedded themes:

Supported file extensions: