RGC for VS Code
English · 中文
English
VS Code support for RGC, a Python-style compiled language with LLVM, static
typing, and ownership/borrow checking.
The extension is a thin LSP client. The language server itself is written in
RGC and speaks the Language Server Protocol over stdio. See
docs/lsp-server-contract.md for the contract.
Features
- Syntax highlighting for
.rg files (TextMate grammar).
- Language configuration:
# / /* */ comments, bracket matching, auto-closing.
- Snippets for
def, class, enum, interface, if, for, while, match,
import, print, and main.
- Commands: build, run, and test the current
.rg file with the rgc compiler.
- LSP client: diagnostics, completion, hover, go-to-definition, and document
symbols are provided by the RGC language server at runtime.
- Bilingual UI (English / 简体中文) through VS Code's localization system.
Requirements
- VS Code 1.85 or newer.
- The
rgc compiler (for the build/run/test commands).
- The RGC language server (for LSP features). It is a separate executable and
is not bundled with this client.
Build and run
cd vscode-rgc
npm install
npm run compile
Then open the vscode-rgc folder in VS Code and press F5 to launch an
Extension Development Host.
To produce a .vsix package:
npm run package
code --install-extension rgc-lang-0.2.0.vsix
Commands
| Command |
Description |
RGC: Build Current File |
rgc <file> -o <output> |
RGC: Run Current File |
rgc run <file> [args...] |
RGC: Test Current File |
rgc test <file> |
RGC: Restart Language Server |
Restart the LSP connection |
The commands run in an integrated terminal, so compiler output and diagnostics
are visible exactly as on the command line.
Configuration
| Setting |
Default |
Description |
rgc.compilerPath |
rgc |
Path to the rgc compiler. |
rgc.lsp.serverPath |
rgc |
Path to the language server executable. |
rgc.lsp.serverArgs |
["lsp", "--stdio"] |
Arguments passed to the server. |
rgc.trace.server |
off |
LSP trace level: off, messages, verbose. |
For a standalone server binary, for example rgc-lsp, set:
{
"rgc.lsp.serverPath": "/path/to/rgc-lsp",
"rgc.lsp.serverArgs": []
}
Testing the client before the RGC server exists
A zero-dependency mock server is included to verify the client wiring:
{
"rgc.lsp.serverPath": "node",
"rgc.lsp.serverArgs": ["/absolute/path/to/vscode-rgc/scripts/mock-rgc-lsp.js"]
}
Open any .rg file. The status bar should show RGC: Ready, and an
informational diagnostic appears on the first line. This only proves that the
client can launch a server, initialize, and receive diagnostics — the real
features come from the RGC-written server.
Repository layout
vscode-rgc/
├── src/ # TypeScript LSP client
├── syntaxes/ # TextMate grammar
├── snippets/ # code snippets
├── l10n/ # runtime translations (en / zh-cn)
├── package.nls*.json # manifest translations (en / zh-cn)
├── resources/ # transparent-background logo and icon
├── scripts/ # icon generator + mock LSP server
└── docs/ # language server contract
中文
RGC 是一门 Python 风格、编译型、静态类型、带所有权/借用检查的语言,
后端使用 LLVM。本扩展为它提供 VS Code 支持。
扩展本身是轻量 LSP 客户端:语言服务器由 RGC 自己编写,通过 stdio 讲
Language Server Protocol。服务器契约见
docs/lsp-server-contract.md。
功能
.rg 文件语法高亮(TextMate 语法)。
- 语言配置:
# / /* */ 注释、括号匹配、自动闭合。
- 代码片段:
def、class、enum、interface、if、for、while、
match、import、print、main。
- 命令:使用
rgc 编译器编译、运行、测试当前 .rg 文件。
- LSP 客户端:诊断、补全、悬停、跳转定义、文档符号,均由运行时的 RGC
语言服务器提供。
- 中英双语界面(通过 VS Code 本地化机制)。
环境要求
- VS Code 1.85 或更新版本。
rgc 编译器(用于编译/运行/测试命令)。
- RGC 语言服务器(用于 LSP 功能)。它是独立可执行文件,不随本客户端打包。
构建与运行
cd vscode-rgc
npm install
npm run compile
然后在 VS Code 中打开 vscode-rgc 目录,按 F5 启动扩展开发宿主。
打包为 .vsix:
npm run package
code --install-extension rgc-lang-0.2.0.vsix
命令
| 命令 |
说明 |
RGC: 编译当前文件 |
rgc <file> -o <output> |
RGC: 运行当前文件 |
rgc run <file> [args...] |
RGC: 测试当前文件 |
rgc test <file> |
RGC: 重启语言服务器 |
重启 LSP 连接 |
命令在集成终端中执行,编译器输出与命令行完全一致。
配置
| 配置项 |
默认值 |
说明 |
rgc.compilerPath |
rgc |
rgc 编译器路径。 |
rgc.lsp.serverPath |
rgc |
语言服务器可执行文件路径。 |
rgc.lsp.serverArgs |
["lsp", "--stdio"] |
传给服务器的参数。 |
rgc.trace.server |
off |
LSP 日志级别:off、messages、verbose。 |
若服务器是独立二进制(如 rgc-lsp):
{
"rgc.lsp.serverPath": "/path/to/rgc-lsp",
"rgc.lsp.serverArgs": []
}
在 RGC 服务器完成前验证客户端
仓库附带一个零依赖 mock 服务器,用于验证客户端接线:
{
"rgc.lsp.serverPath": "node",
"rgc.lsp.serverArgs": ["/absolute/path/to/vscode-rgc/scripts/mock-rgc-lsp.js"]
}
打开任意 .rg 文件,状态栏应显示 RGC: 已就绪,首行出现一条信息级诊断。
这只证明客户端能够启动服务器、完成初始化并接收诊断;真正的功能来自 RGC
编写的服务器。
目录结构
vscode-rgc/
├── src/ # TypeScript LSP 客户端
├── syntaxes/ # TextMate 语法高亮
├── snippets/ # 代码片段
├── l10n/ # 运行时翻译(en / zh-cn)
├── package.nls*.json # 扩展清单翻译(en / zh-cn)
├── resources/ # 透明背景 logo 与图标
├── scripts/ # 图标生成脚本 + mock LSP 服务器
└── docs/ # 语言服务器契约
License
Apache-2.0. The logo is generated for the RGC project.