Skip to content

Commit 4e3e539

Browse files
committed
feat: Add initial ProXPL VS Code extension with run command, formatting, hover support, and quickstart guide.
1 parent c248b98 commit 4e3e539

3 files changed

Lines changed: 64 additions & 5 deletions

File tree

extension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
],
5858
"commands": [
5959
{
60-
"command": "proxpl.runFile",
60+
"command": "proxpl.run",
6161
"title": "ProXPL: Run File",
6262
"icon": "$(play)"
6363
}
@@ -66,7 +66,7 @@
6666
"editor/title": [
6767
{
6868
"when": "resourceExtname == .prox",
69-
"command": "proxpl.runFile",
69+
"command": "proxpl.run",
7070
"group": "navigation"
7171
}
7272
]

extension/src/extension.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function activate(context: vscode.ExtensionContext) {
66
context.subscriptions.push(diagnosticCollection);
77

88
// 1. Code Runner Command
9-
let runCommand = vscode.commands.registerCommand('proxpl.runFile', () => {
9+
let runCommand = vscode.commands.registerCommand('proxpl.run', () => {
1010
const editor = vscode.window.activeTextEditor;
1111
if (!editor) {
1212
vscode.window.showErrorMessage('No active editor found.');
@@ -67,17 +67,30 @@ export function activate(context: vscode.ExtensionContext) {
6767
const formattingProvider = vscode.languages.registerDocumentFormattingEditProvider('proxpl', {
6868
provideDocumentFormattingEdits(document: vscode.TextDocument): vscode.TextEdit[] {
6969
const edits: vscode.TextEdit[] = [];
70+
let lastLineWasEmpty = false;
7071

7172
for (let i = 0; i < document.lineCount; i++) {
7273
const line = document.lineAt(i);
7374
const text = line.text;
7475

75-
// Remove trailing whitespace
76+
// 1. Remove extra empty lines (consecutive empty lines)
77+
if (text.trim() === '') {
78+
if (lastLineWasEmpty) {
79+
// Delete this extra empty line
80+
edits.push(vscode.TextEdit.delete(line.rangeIncludingLineBreak));
81+
continue;
82+
}
83+
lastLineWasEmpty = true;
84+
} else {
85+
lastLineWasEmpty = false;
86+
}
87+
88+
// 2. Remove trailing whitespace
7689
if (text.endsWith(' ') || text.endsWith('\t')) {
7790
edits.push(vscode.TextEdit.delete(new vscode.Range(i, text.trimEnd().length, i, text.length)));
7891
}
7992

80-
// Basic Indentation
93+
// 3. Basic Indentation (Fix to 4 spaces)
8194
const indentMatch = text.match(/^(\s+)/);
8295
if (indentMatch) {
8396
const oldIndent = indentMatch[1];
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# VS Code Extension Quickstart for ProXPL
2+
3+
Follow these steps to compile and test the extension features (Run Code, Formatter, and Hover Support).
4+
5+
## Prerequisites
6+
7+
Ensure you have [Node.js](https://nodejs.org/) installed, which includes `npm`.
8+
9+
## 1. Install Dependencies
10+
11+
Open a terminal in the `extension/` directory and run:
12+
13+
```bash
14+
npm install
15+
```
16+
17+
This will install the VS Code API types and the TypeScript compiler.
18+
19+
## 2. Compile the TypeScript Code
20+
21+
To translate the `.ts` files into executable `.js` files in the `out/` directory:
22+
23+
```bash
24+
npm run compile
25+
```
26+
27+
If you want to keep the compiler running and watching for changes:
28+
29+
```bash
30+
npm run watch
31+
```
32+
33+
## 3. Launch and Test the Extension
34+
35+
1. In the current VS Code window (where the `extension/` folder is open), press **F5**.
36+
2. A new window titled **[Extension Development Host]** will open.
37+
3. In that new window, open or create a file with the `.prox` extension (e.g., `hello.prox`).
38+
4. **Test Run Code**: Click the **Play button** in the top-right corner of the editor.
39+
5. **Test Hover**: Hover over keywords like `func`, `var`, or `print`.
40+
6. **Test Formatter**: Right-click in the editor and select **Format Document** (or use `Alt+Shift+F`).
41+
42+
## 4. Troubleshooting
43+
44+
- If the **Play button** doesn't appear, ensure the file ends in `.prox`.
45+
- If the terminal says `proxpl not found`, ensure the ProXPL compiler is installed and added to your system PATH.
46+
- If changes aren't reflected, ensure you've run `npm run compile` and restarted the host window via the debug toolbar.

0 commit comments

Comments
 (0)