Skip to content

Commit

Permalink
Add syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
didrikmunther committed Sep 20, 2024
1 parent 34d3931 commit 4f8c923
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dependency.ro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub fn print_two_numbers(a: int, b: int) {
a = a + 1;
b = b * 2;

printf("%i %i", a, b);
}
4 changes: 4 additions & 0 deletions input.ro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let a = 1 + 2;
let b = c + 3 * 4;

print_two_numbers(a, b);
5 changes: 4 additions & 1 deletion lsp-client/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export function activate(context: ExtensionContext) {
// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{ language: "plaintext" }],
documentSelector: [{
scheme: "file",
language: "rost",
}],
// synchronize: {
// // Notify the server about file changes to '.clientrc files contained in the workspace
// fileEvents: workspace.createFileSystemWatcher("**/.clientrc"),
Expand Down
23 changes: 21 additions & 2 deletions lsp-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,30 @@
"engines": {
"vscode": "^1.75.0"
},
"main": "./client/out/extension",
"activationEvents": [
"onLanguage:plaintext"
"onLanguage:rost"
],
"main": "./client/out/extension",
"contributes": {
"languages": [
{
"id": "rost",
"aliases": [
"Rost",
"rost"
],
"extensions": [
".ro"
]
}
],
"grammars": [
{
"language": "rost",
"scopeName": "source.rost",
"path": "./syntaxes/rost.tmLanguage.json"
}
],
"configuration": {
"type": "object",
"title": "Example configuration",
Expand Down
82 changes: 82 additions & 0 deletions lsp-client/syntaxes/rost.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"scopeName": "source.rost",
"patterns": [
{
"name": "meta.function-call.rost",
"match": "(\\b[a-zA-Z_][a-zA-Z0-9_]*\\b)\\s*\\(",
"captures": {
"1": {
"name": "support.function.builtin.rost"
}
}
},
{
"name": "comment.block.rost",
"begin": "/\\*",
"end": "\\*/"
},
{
"name": "comment.line.rost",
"begin": "/\\*",
"end": "\\*/"
},
{
"name": "comment.line.double-slash.rost",
"match": "//.*$"
},
{
"name": "keyword.control.rost",
"match": "\\b(pub|let|fn|if|else|for|while|return)\\b"
},
{
"name": "string.quoted.double.rost",
"begin": "\"",
"end": "\""
},
{
"name": "constant.numeric.rost",
"match": "\\b\\d+\\b"
},
{
"name": "variable.other.rost",
"match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b"
},
{
"name": "punctuation.terminator.rost",
"match": ";"
},
{
"name": "punctuation.separator.rost",
"match": ","
},
{
"name": "punctuation.bracket.rost",
"match": "[\\[\\]\\(\\)\\{\\}]"
},
{
"name": "operator.arithmetic.rost",
"match": "[\\+\\-\\*\\/\\%]"
},
{
"name": "operator.comparison.rost",
"match": "[\\=\\!\\<\\>]"
},
{
"name": "operator.assignment.rost",
"match": "="
},
{
"name": "storage.type.rost",
"match": "\\b(int|float|double|char|void)\\b"
},
{
"name": "storage.class.rost",
"match": "\\b(struct|enum)\\b"
}
],
"repository": {},
"name": "Rost",
"fileTypes": [
".ro"
]
}

0 comments on commit 4f8c923

Please sign in to comment.