@repometry/language-lua 0.0.0-dev.0 → 0.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Idleware
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,14 +1,44 @@
1
1
  {
2
2
  "name": "@repometry/language-lua",
3
- "version": "0.0.0-dev.0",
4
- "description": "Reserved for Repometry: Lua language support. Not usable yet.",
3
+ "version": "0.0.0",
4
+ "description": "Lua for the Repometry tree-sitter plugin, with its grammar",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/idleware/repometry.git"
9
9
  },
10
10
  "homepage": "https://github.com/idleware/repometry#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/idleware/repometry/issues"
13
+ },
14
+ "keywords": [
15
+ "repometry",
16
+ "tree-sitter",
17
+ "lua"
18
+ ],
19
+ "type": "module",
20
+ "engines": {
21
+ "node": ">=24"
22
+ },
23
+ "exports": {
24
+ ".": {
25
+ "types": "./target/main/ts/index.d.ts",
26
+ "default": "./target/main/ts/index.js"
27
+ }
28
+ },
29
+ "files": [
30
+ "target/main",
31
+ "!target/main/**/*.map"
32
+ ],
11
33
  "publishConfig": {
12
34
  "access": "public"
35
+ },
36
+ "scripts": {
37
+ "build": "node -e \"require('node:fs').rmSync('target/main', { recursive: true, force: true })\" && tsc -p tsconfig.json && node -e \"const fs = require('node:fs'); fs.cpSync('src/main/resources', 'target/main/resources', { recursive: true }); fs.cpSync('../../LICENSE', 'LICENSE')\"",
38
+ "prepack": "npm run build"
39
+ },
40
+ "dependencies": {
41
+ "@repometry/core": "0.4.0",
42
+ "@repometry/tree-sitter": "0.3.0"
13
43
  }
14
44
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "package": "@tree-sitter-grammars/tree-sitter-lua",
3
+ "version": "0.5.0",
4
+ "license": "MIT",
5
+ "source": "https://github.com/tree-sitter-grammars/tree-sitter-lua/releases/download/v0.5.0/tree-sitter-lua.wasm",
6
+ "sha256": "df08a1704e504c70b8dba4a3e6f8e0c99a4fb94e1b1693d2969f53141d09f0d4"
7
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Munif Tanjim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ import { lua } from './lua.js';
2
+ export { lua };
3
+ declare const _default: import("@repometry/core").PluginManifest<import("@repometry/core/internal/model/plugin-data.js").JsonValue> & {
4
+ readonly version: string;
5
+ create(): Awaited<ReturnType<import("@repometry/core").PluginManifest['create']>>;
6
+ };
7
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { treeSitter } from '@repometry/tree-sitter';
2
+ import { lua } from './lua.js';
3
+ export { lua };
4
+ export default treeSitter(lua);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import type { LanguageUnit as Grammar } from '@repometry/tree-sitter';
2
+ export declare const lua: Grammar;
@@ -0,0 +1,62 @@
1
+ import { measures } from '@repometry/tree-sitter';
2
+ import manifest from '../resources/grammar.json' with { type: 'json' };
3
+ function name(node) {
4
+ const declared = node.childForFieldName('name');
5
+ if (!declared || declared.type === 'identifier')
6
+ return declared?.text;
7
+ const parts = declared.descendantsOfType('identifier').map(part => part.text);
8
+ const method = declared.type === 'method_index_expression' ? parts.pop() : undefined;
9
+ return parts.join('.') + (method === undefined ? '' : ':' + method);
10
+ }
11
+ function parameterCount(node) {
12
+ let count = 0;
13
+ for (const parameter of node.childForFieldName('parameters')?.namedChildren ?? []) {
14
+ // Lua 5.5 can name the final vararg. It is still one parameter.
15
+ if (parameter.type === 'vararg_expression')
16
+ return count + 1;
17
+ if (parameter.type === 'identifier')
18
+ count++;
19
+ }
20
+ return count;
21
+ }
22
+ const tokens = {
23
+ candidates: new Set([
24
+ 'assignment_statement', 'block', 'break_statement', 'do_statement', 'else_statement', 'elseif_statement',
25
+ 'field', 'for_statement', 'function_call', 'function_declaration', 'function_definition', 'goto_statement',
26
+ 'if_statement', 'implicit_variable_declaration', 'repeat_statement', 'return_statement',
27
+ 'table_constructor', 'variable_declaration', 'while_statement',
28
+ ]),
29
+ kinds: new Map([
30
+ ['identifier', 'identifier'], ['number', 'number'], ['string', 'string'],
31
+ ['true', 'boolean'], ['false', 'boolean'], ['nil', 'nil'],
32
+ ]),
33
+ };
34
+ export const lua = {
35
+ language: {
36
+ id: 'lua', label: 'Lua', color: '#000080', extensions: ['.lua'], measures,
37
+ // Long brackets may use any number of equals signs; keep the viewer's forms line-scoped.
38
+ syntax: {
39
+ lineComments: ['--'], strings: [{ quote: "'" }, { quote: '"' }],
40
+ keywords: ['and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'goto', 'if', 'in',
41
+ 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', 'true', 'until', 'while'],
42
+ },
43
+ },
44
+ tool: { package: manifest.package, version: manifest.version },
45
+ asset: new URL('../resources/tree-sitter.wasm', import.meta.url),
46
+ prepareSource: text => text,
47
+ columns: 'codepoints', name,
48
+ rules: {
49
+ function_declaration: { flow: 'function', parameters: parameterCount },
50
+ function_definition: { flow: 'function', parameters: parameterCount },
51
+ if_statement: { flow: 'if', decision: true }, elseif_statement: { flow: 'elif', decision: true },
52
+ else_statement: { flow: 'else' },
53
+ for_statement: { flow: 'nest', decision: true }, while_statement: { flow: 'nest', decision: true },
54
+ repeat_statement: { flow: 'nest', decision: true },
55
+ goto_statement: { exit: 'label' }, return_statement: { exit: 'return' },
56
+ },
57
+ parens: new Set(['parenthesized_expression']), comments: new Set(['comment', 'hash_bang_line']),
58
+ extras: new Set(),
59
+ logicalTypes: new Set(['binary_expression']), logicalOperators: new Set(['and', 'or']), logicalCognitive: 'parent',
60
+ moduleDepthLabel: 'Module · Control-flow depth', tokens,
61
+ };
62
+ //# sourceMappingURL=lua.js.map
package/README.md DELETED
@@ -1,4 +0,0 @@
1
- # @repometry/language-lua
2
-
3
- Reserved for [Repometry](https://github.com/idleware/repometry): Lua language support.
4
- This version is a placeholder with no code. Use the `repometry` package until a release appears here.