@repometry/language-rust 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repometry/language-rust",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Rust for the Repometry tree-sitter plugin, with its grammar",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prepack": "npm run build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@repometry/core": "0.
|
|
42
|
-
"@repometry/tree-sitter": "0.5.
|
|
41
|
+
"@repometry/core": "0.8.0",
|
|
42
|
+
"@repometry/tree-sitter": "0.5.2"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const rustSyntax = {
|
|
2
|
+
lineComments: ['//'],
|
|
3
|
+
blockComments: [['/*', '*/']],
|
|
4
|
+
nestedBlockComments: true,
|
|
5
|
+
strings: [
|
|
6
|
+
...['r', 'br', 'cr'].flatMap(prefix => Array.from({ length: 8 - prefix.length }, (_, count) => {
|
|
7
|
+
const hashes = '#'.repeat(count);
|
|
8
|
+
return { quote: prefix + hashes + '"', end: '"' + hashes, raw: true, multiline: true };
|
|
9
|
+
})),
|
|
10
|
+
{ quote: '"' },
|
|
11
|
+
],
|
|
12
|
+
stringPrefixes: ['b', 'c'],
|
|
13
|
+
keywords: ['as', 'async', 'await', 'break', 'const', 'continue', 'crate', 'dyn', 'else', 'enum', 'extern', 'false',
|
|
14
|
+
'fn', 'for', 'if', 'impl', 'in', 'let', 'loop', 'match', 'mod', 'move', 'mut', 'pub', 'ref', 'return', 'self',
|
|
15
|
+
'Self', 'static', 'struct', 'super', 'trait', 'true', 'type', 'unsafe', 'use', 'where', 'while', 'abstract',
|
|
16
|
+
'become', 'box', 'do', 'final', 'gen', 'macro', 'override', 'priv', 'try', 'typeof', 'unsized', 'virtual',
|
|
17
|
+
'yield'],
|
|
18
|
+
};
|
package/target/main/ts/rust.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { measures } from '@repometry/tree-sitter';
|
|
2
2
|
import manifest from '../resources/grammar.json' with { type: 'json' };
|
|
3
|
+
import { rustSyntax } from './rust-syntax.js';
|
|
3
4
|
const classTypes = ['struct_item', 'enum_item', 'union_item', 'trait_item'];
|
|
4
5
|
const functionTypes = ['function_item', 'closure_expression'];
|
|
5
6
|
const loops = ['for_expression', 'while_expression', 'loop_expression'];
|
|
@@ -53,7 +54,7 @@ const tokens = {
|
|
|
53
54
|
]),
|
|
54
55
|
};
|
|
55
56
|
export const rust = {
|
|
56
|
-
language: { id: 'rust', label: 'Rust', color: '#dea584', extensions: ['.rs'], measures: [...measures, 'classes'] },
|
|
57
|
+
language: { id: 'rust', label: 'Rust', color: '#dea584', extensions: ['.rs'], measures: [...measures, 'classes'], syntax: rustSyntax },
|
|
57
58
|
tool: { package: manifest.package, version: manifest.version },
|
|
58
59
|
asset: new URL('../resources/tree-sitter.wasm', import.meta.url),
|
|
59
60
|
prepareSource: text => text,
|