Sublime Text currently ships without Clarity syntax definitions. Here’s the process I followed to make my own .sublime-syntax files.
The syntax definitions for Clarity that I found online are maintained by Hiro, targeting VS Code and shipped as TextMate grammars.
1. Clone the reference syntax definitions:
git clone https://github.com/hirosystems/clarity-lsp
cd clarity-lsp
# Optionally, go to the exact same commit I used.
git checkout a1e2808e13a8c4de4993389eb409d7c359248bcd
cd editors/code/syntaxes
# We will be explicitly converting this afterwards.
rm clarity.tmLanguage.json
2. Convert clarity.yaml
to clarity.json
:
npm install js-yaml@4.1.0
# Convert:
# yaml TextMate grammar ->
# json TextMate grammar
npx js-yaml clarity.yaml > clarity.json
3. Convert clarity.json
to clarity.tmLanguage
:
# https://github.com/Togusa09/vscode-tmlanguage
code --install-extension Togusa09.tmlanguage
code clarity.json
# Then, use the 'Convert to tmLanguage File' command, save.
4. Convert clarity.tmLanguage
to clarity.sublime-syntax
:
subl clarity.tmLanguage
# Then, use the 'Convert Syntax to .syblime-syntax` command, save.
5. Define the file extensions this syntax should be used for. Add the following to clarity.sublime-syntax
:
file_extensions:
- clar
For convenience, here’s the diff after adding it:
--- a/Data/Packages/User/clarity.sublime-syntax
+++ b/Data/Packages/User/clarity.sublime-syntax
@@ -2,6 +2,8 @@
---
# http://www.sublimetext.com/docs/syntax.html
name: clarity
+file_extensions:
+ - clar
scope: source.clar
contexts:
main:
Get clarity-sublime-syntax on github.