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. This service is horizontally scalable, but please give #21942 and #32359 a read before scaling it up.
cargo run --bin syntect_serverYou can set the SRC_SYNTECT_SERVER environment var to whatever port this
connects to and test against local Sourcegraph instance.
docker run --detach --name=syntax-highlighter -p 9238:9238 sourcegraph/syntax-highlighterYou can then e.g. GET http://localhost:9238/health or http://host.docker.internal:9238/health to confirm it is working.
See API
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.
rustupshould automatically detect what version of rust is in the./rust-toolchainfile.- Use
cargo test --workspaceto run all the tests - Use
cargo run --bin syntect_serverto run the server locally. - You can change the
SRC_SYNTECT_SERVERoption in yoursg.config.yamlto point to whatever port you're running on (usually 8000) and test against that without building the docker image.
./build.sh will build your current repository checkout into a final Docker image. You DO NOT need to do this when you push to get it publish. But, you should do this to make sure that it is possible to build the image 😄.
AGAIN NOTE: The docker image will be published automatically via CI.
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.
TODO: Maybe we can just remove themes entirely. I think they are u
- Copy a
.tmThemefile anywhere under./syntect/testdata(make a new dir if needed) in our fork. cd syntect && make assets- In this repo,
cargo update -p syntect. - Build a new binary.
TODO: Update these instructions once we move to sourcegraph/syntect.
https://github.com/sourcegraph/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
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:
- https://github.com/slimsag/syntect/commit/9976d2095e49fd91607026364466cd7b389b938e
- https://github.com/slimsag/syntect/commit/1182dd3bd7c82b6655d8466c9896a1e4f458c71e
Run the following in this directory.
$ cargo update -p syntect
Run: cargo run --bin syntect_server to see supported languages and themes.