GitNexus/gitnexus-shared/src/languages.ts
taoxin 8e7da9d844 feat(languages): add Lua language support
Add Lua as a supported language with symbol extraction and scope-resolution
at parity with existing languages.

Vendored grammar:
- Vendor tree-sitter-lua (v2.1.3, MIT). Upstream ships nan-based node
  bindings incompatible with the pinned tree-sitter@0.21.1 runtime
  (setLanguage rejects with "Invalid language object"), so the grammar C
  sources are rebuilt against a Napi binding adapted from tree-sitter-c.

Symbol extraction (legacy tree-sitter queries):
- Function, Method, and Class definitions; call sites.

Scope-resolution (CALLS + IMPORTS edges):
- emitScopeCaptures, interpretImport, and a Lua ScopeResolver registered
  in the scope-resolution pipeline.
- Import resolution via a SuffixIndex so root-level modules (e.g.
  require("middleclass")) resolve, not just dotted paths.

Class structure (EXTENDS + HAS_METHOD + METHOD_OVERRIDES):
- middleclass class("Name", Parent) and function Class:method() handled
  via a heritage edge hook (emitHeritageEdges), since middleclass has no
  syntactic class body for the standard heritage/ownership walk.

Registered in all dispatch tables (SupportedLanguages enum, language
detection, parser-loader, parse-worker languageMap, language
classification, scope-resolver registry, vendored-grammar manifest).

Verified: tsc --noEmit clean; analyze on a Lua sample produces Class,
Method, EXTENDS, HAS_METHOD, METHOD_OVERRIDES, IMPORTS, and CALLS.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-10-12 17:56:37 +08:00

28 lines
703 B
TypeScript

/**
* Supported language enum — single source of truth.
*
* Both CLI and web use this to identify which language a file/node belongs to.
* The CLI uses it throughout the ingestion pipeline; the web uses it for display.
*/
export enum SupportedLanguages {
JavaScript = 'javascript',
TypeScript = 'typescript',
Python = 'python',
Java = 'java',
C = 'c',
CPlusPlus = 'cpp',
ObjectiveC = 'objective-c',
CSharp = 'csharp',
Go = 'go',
Ruby = 'ruby',
Rust = 'rust',
PHP = 'php',
Kotlin = 'kotlin',
Swift = 'swift',
Dart = 'dart',
Vue = 'vue',
Lua = 'lua',
/** Standalone regex processor — no tree-sitter, no LanguageProvider. */
Cobol = 'cobol',
Zig = 'zig',
}