Skip to content

Commit fd73c0b

Browse files
committed
Initial VS Code extension setup
Migrate VS Code extension from main t-ruby repository: - TypeScript extension with LSP support - CI/CD workflows for VS Code Marketplace and Open VSX - README with Cursor section and dynamic badges - Local publish script
1 parent 148eec8 commit fd73c0b

File tree

19 files changed

+4596
-1
lines changed

19 files changed

+4596
-1
lines changed

.eslintrc.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 2020,
6+
"sourceType": "module"
7+
},
8+
"plugins": [
9+
"@typescript-eslint"
10+
],
11+
"extends": [
12+
"eslint:recommended",
13+
"plugin:@typescript-eslint/recommended"
14+
],
15+
"rules": {
16+
"@typescript-eslint/naming-convention": "off",
17+
"@typescript-eslint/semi": "warn",
18+
"curly": "warn",
19+
"eqeqeq": "warn",
20+
"no-throw-literal": "warn",
21+
"semi": "off"
22+
},
23+
"ignorePatterns": [
24+
"out",
25+
"dist",
26+
"**/*.d.ts"
27+
]
28+
}

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Lint
26+
run: npm run lint
27+
28+
- name: Compile
29+
run: npm run compile
30+
31+
- name: Build VSIX
32+
run: |
33+
npm install -g @vscode/vsce
34+
vsce package

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
cache: 'npm'
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Compile
25+
run: npm run compile
26+
27+
- name: Install vsce and ovsx
28+
run: |
29+
npm install -g @vscode/vsce
30+
npm install -g ovsx
31+
32+
- name: Package extension
33+
run: vsce package
34+
35+
- name: Publish to VS Code Marketplace
36+
run: vsce publish
37+
env:
38+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
39+
40+
- name: Publish to Open VSX (Cursor)
41+
run: ovsx publish *.vsix
42+
env:
43+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
44+
45+
- name: Create GitHub Release
46+
uses: softprops/action-gh-release@v1
47+
with:
48+
files: '*.vsix'
49+
generate_release_notes: true
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.vscodeignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Source files (compiled output in out/ is sufficient)
2+
src/
3+
*.ts
4+
!*.d.ts
5+
6+
# TypeScript config
7+
tsconfig.json
8+
9+
# Package lock (not needed at runtime)
10+
package-lock.json
11+
12+
# Source maps (optional, can be included for debugging)
13+
out/**/*.map
14+
15+
# Development files
16+
.vscode/
17+
.github/
18+
.git/
19+
20+
# Test files
21+
**/*.test.ts
22+
**/test/
23+
24+
# Build artifacts
25+
*.vsix

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Changelog
2+
3+
All notable changes to the T-Ruby VS Code extension will be documented in this file.
4+
5+
## [0.1.0] - 2024-12-10
6+
7+
### Added
8+
9+
- Initial release
10+
- Syntax highlighting for `.trb` and `.d.trb` files
11+
- Language Server Protocol (LSP) integration
12+
- Real-time diagnostics and type error reporting
13+
- IntelliSense with autocomplete suggestions
14+
- Go to Definition support
15+
- Hover information for types
16+
- Find References functionality
17+
- Commands:
18+
- Compile Current File
19+
- Generate Declaration File
20+
- Restart Language Server

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 type-ruby
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.

README.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,82 @@
1-
# t-ruby-vscode
1+
# T-Ruby for Visual Studio Code
2+
3+
[![VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/t-ruby.t-ruby?label=VS%20Code%20Marketplace)](https://marketplace.visualstudio.com/items?itemName=t-ruby.t-ruby)
4+
[![Open VSX](https://img.shields.io/open-vsx/v/t-ruby/t-ruby?label=Open%20VSX)](https://open-vsx.org/extension/t-ruby/t-ruby)
5+
[![VS Code Installs](https://img.shields.io/visual-studio-marketplace/i/t-ruby.t-ruby)](https://marketplace.visualstudio.com/items?itemName=t-ruby.t-ruby)
6+
[![T-Ruby Compiler](https://img.shields.io/gem/v/t-ruby?label=T-Ruby%20Compiler)](https://rubygems.org/gems/t-ruby)
7+
[![License](https://img.shields.io/github/license/type-ruby/t-ruby-vscode)](LICENSE)
8+
9+
T-Ruby language support for Visual Studio Code. Provides syntax highlighting, LSP-based code intelligence, and development tools for [T-Ruby](https://github.com/type-ruby/t-ruby) - a TypeScript-style static type system for Ruby.
10+
11+
## Features
12+
13+
- Syntax highlighting for `.trb` and `.d.trb` files
14+
- LSP-based code intelligence:
15+
- Real-time diagnostics (type errors)
16+
- Autocomplete suggestions
17+
- Go to definition
18+
- Hover information
19+
- Commands:
20+
- `T-Ruby: Compile Current File` - Compile the current `.trb` file
21+
- `T-Ruby: Generate Declaration File` - Generate `.d.trb` declaration file
22+
- `T-Ruby: Restart Language Server` - Restart the LSP server
23+
24+
## Requirements
25+
26+
- [T-Ruby Compiler](https://github.com/type-ruby/t-ruby) (`trc`) must be installed and available in your PATH
27+
28+
```bash
29+
gem install t-ruby
30+
```
31+
32+
## Installation
33+
34+
### VS Code
35+
36+
Install from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=t-ruby.t-ruby):
37+
38+
1. Open VS Code
39+
2. Go to Extensions (Ctrl+Shift+X)
40+
3. Search for "T-Ruby"
41+
4. Click Install
42+
43+
Or install via command line:
44+
45+
```bash
46+
code --install-extension t-ruby.t-ruby
47+
```
48+
49+
## Cursor
50+
51+
This extension is also available for [Cursor](https://cursor.com), a fork of VS Code.
52+
53+
- **Same codebase**: Cursor uses the same extension code as VS Code
54+
- **Different marketplace**: Install from Open VSX Registry instead of VS Code Marketplace
55+
56+
Install for Cursor:
57+
- Open VSX: https://open-vsx.org/extension/t-ruby/t-ruby
58+
59+
## Configuration
60+
61+
| Setting | Default | Description |
62+
|---------|---------|-------------|
63+
| `t-ruby.lspPath` | `trc` | Path to the T-Ruby compiler executable |
64+
| `t-ruby.enableLSP` | `true` | Enable Language Server Protocol support |
65+
| `t-ruby.diagnostics.enable` | `true` | Enable real-time diagnostics |
66+
| `t-ruby.completion.enable` | `true` | Enable autocomplete suggestions |
67+
68+
## Compatibility
69+
70+
| Extension Version | T-Ruby Compiler |
71+
|-------------------|-----------------|
72+
| 0.1.x | >= 0.0.30 |
73+
74+
## Related
75+
76+
- [T-Ruby Compiler](https://github.com/type-ruby/t-ruby) - The main T-Ruby compiler
77+
- [T-Ruby JetBrains](https://github.com/type-ruby/t-ruby-jetbrains) - JetBrains IDE plugin
78+
- [T-Ruby Vim](https://github.com/type-ruby/t-ruby-vim) - Vim/Neovim plugin
79+
80+
## License
81+
82+
MIT

icon.png

49.7 KB
Loading

icons/t-ruby.svg

Lines changed: 23 additions & 0 deletions
Loading

language-configuration.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"comments": {
3+
"lineComment": "#",
4+
"blockComment": ["=begin", "=end"]
5+
},
6+
"brackets": [
7+
["{", "}"],
8+
["[", "]"],
9+
["(", ")"]
10+
],
11+
"autoClosingPairs": [
12+
{ "open": "{", "close": "}" },
13+
{ "open": "[", "close": "]" },
14+
{ "open": "(", "close": ")" },
15+
{ "open": "\"", "close": "\"" },
16+
{ "open": "'", "close": "'" },
17+
{ "open": "|", "close": "|" },
18+
{ "open": "<", "close": ">" }
19+
],
20+
"surroundingPairs": [
21+
{ "open": "{", "close": "}" },
22+
{ "open": "[", "close": "]" },
23+
{ "open": "(", "close": ")" },
24+
{ "open": "\"", "close": "\"" },
25+
{ "open": "'", "close": "'" },
26+
{ "open": "<", "close": ">" }
27+
],
28+
"indentationRules": {
29+
"increaseIndentPattern": "^\\s*(module|class|def|if|unless|case|while|until|for|begin|do|interface)\\b.*$",
30+
"decreaseIndentPattern": "^\\s*(end|else|elsif|when|rescue|ensure)\\b.*$"
31+
},
32+
"folding": {
33+
"markers": {
34+
"start": "^\\s*(module|class|def|if|unless|case|while|until|for|begin|do|interface)\\b",
35+
"end": "^\\s*end\\b"
36+
}
37+
},
38+
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)"
39+
}

0 commit comments

Comments
 (0)