Skip to content

Merge VSCode extension from pony-language-server repo#2

Merged
SeanTAllen merged 34 commits intoponylang:mainfrom
orien:merge-pony-language-server
Feb 4, 2026
Merged

Merge VSCode extension from pony-language-server repo#2
SeanTAllen merged 34 commits intoponylang:mainfrom
orien:merge-pony-language-server

Conversation

@orien
Copy link
Copy Markdown
Member

@orien orien commented Feb 1, 2026

In preparation for archiving the pony-language-server GitHub repository, move the VSCode extension source code into this dedicated repository.

hover

For transparency, these are the changes I made on top of the copied code:

Details

diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index 68765e9..28f8b47 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -38,9 +38,10 @@ jobs:
     steps:
       - name: Checkout source
         uses: actions/checkout@v4.1.1
-      - name: Install npm
-        run: sudo apt-get install -y --no-install-recommends npm
-      - name: Install vsce
-        run: npm install -g @vscode/vsce
+      - name: Install Node.js
+        uses: actions/setup-node@v6.2.0
+        with:
+          node-version: '22.x'
+          cache: 'npm'
       - name: Build
-        run: make vscode_extension config=debug
+        run: make config=debug
diff --git a/.gitignore b/.gitignore
index e69de29..ee85fdc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,15 @@
+build/
+dist/
+node_modules/
+out/
+
+.*
+!.vscode/
+!.github
+!.release-notes
+!.gitattributes
+!.gitignore
+!.markdownlintignore
+!.vscodeignore
+!.vscodeignore
+*.vsix
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..d7a3ca1
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,5 @@
+{
+  // See http://go.microsoft.com/fwlink/?LinkId=827846
+  // for the documentation about the extensions.json format
+  "recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers", "ms-vscode.extension-test-runner"]
+}
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..c42edc0
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,21 @@
+// A launch configuration that compiles the extension and then opens it inside a new window
+// Use IntelliSense to learn about possible attributes.
+// Hover to view descriptions of existing attributes.
+// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+{
+	"version": "0.2.0",
+	"configurations": [
+		{
+			"name": "Run Extension",
+			"type": "extensionHost",
+			"request": "launch",
+			"args": [
+				"--extensionDevelopmentPath=${workspaceFolder}"
+			],
+			"outFiles": [
+				"${workspaceFolder}/dist/**/*.js"
+			],
+			"preLaunchTask": "${defaultBuildTask}"
+		}
+	]
+}
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..5c5ac48
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,13 @@
+// Place your settings in this file to overwrite default and user settings.
+{
+    "files.exclude": {
+        "out": false, // set this to true to hide the "out" folder with the compiled JS files
+        "dist": false // set this to true to hide the "dist" folder with the compiled JS files
+    },
+    "search.exclude": {
+        "out": true, // set this to false to include "out" folder in search results
+        "dist": true // set this to false to include "dist" folder in search results
+    },
+    // Turn off tsc task auto detection since we have the necessary tasks as npm scripts
+    "typescript.tsc.autoDetect": "off"
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..3cf99c3
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,64 @@
+// See https://go.microsoft.com/fwlink/?LinkId=733558
+// for the documentation about the tasks.json format
+{
+	"version": "2.0.0",
+	"tasks": [
+		{
+            "label": "watch",
+            "dependsOn": [
+                "npm: watch:tsc",
+                "npm: watch:esbuild"
+            ],
+            "presentation": {
+                "reveal": "never"
+            },
+            "group": {
+                "kind": "build",
+                "isDefault": true
+            }
+        },
+        {
+            "type": "npm",
+            "script": "watch:esbuild",
+            "group": "build",
+            "problemMatcher": "$esbuild-watch",
+            "isBackground": true,
+            "label": "npm: watch:esbuild",
+            "presentation": {
+                "group": "watch",
+                "reveal": "never"
+            }
+        },
+		{
+            "type": "npm",
+            "script": "watch:tsc",
+            "group": "build",
+            "problemMatcher": "$tsc-watch",
+            "isBackground": true,
+            "label": "npm: watch:tsc",
+            "presentation": {
+                "group": "watch",
+                "reveal": "never"
+            }
+        },
+		{
+			"type": "npm",
+			"script": "watch-tests",
+			"problemMatcher": "$tsc-watch",
+			"isBackground": true,
+			"presentation": {
+				"reveal": "never",
+				"group": "watchers"
+			},
+			"group": "build"
+		},
+		{
+			"label": "tasks: watch-tests",
+			"dependsOn": [
+				"npm: watch",
+				"npm: watch-tests"
+			],
+			"problemMatcher": []
+		}
+	]
+}
diff --git a/.vscodeignore b/.vscodeignore
index 7d1d661..8552920 100644
--- a/.vscodeignore
+++ b/.vscodeignore
@@ -1,4 +1,10 @@
-.vscode
-node_modules
+.github/
+.release-notes/
+.vscode/
+node_modules/
 src/
+.markdownlintignore
+.gitignore
+Makefile
+VERSION
 tsconfig.json
diff --git a/Makefile b/Makefile
index 0237c62..9acffdd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-PONY_VERSION := 0.58.4
+VERSION := $(shell cat VERSION)
 
 config ?= release
 ifdef config
@@ -8,29 +8,25 @@ ifdef config
 endif
 
 
-BUILD_DIR := ../build/$(config)
+BUILD_DIR := build/$(config)
 DIST_DIR := dist
 SRC_DIR := src
 EXTENSION_JS := $(DIST_DIR)/extension.js
-EXTENSION := $(BUILD_DIR)/pony-lsp-$(PONY_VERSION).vsix
+EXTENSION := $(BUILD_DIR)/pony-$(VERSION).vsix
 SOURCE_FILES := $(shell find $(SRC_DIR) -name *.ts)
 
 all: $(EXTENSION)
 
-$(EXTENSION): $(SOURCE_FILES) pony-lsp node_modules
-	vsce package -o $(BUILD_DIR) $(PONY_VERSION)
+$(EXTENSION): $(SOURCE_FILES) $(BUILD_DIR) node_modules $(BUILD_DIR)
+	npm run vsce package -- --no-git-tag-version --out="$(BUILD_DIR)/pony-$(VERSION).vsix" "$(VERSION)"
 
 node_modules:
 	npm install
 
-pony-lsp: $(BUILD_DIR)/pony-lsp
-	cp $(BUILD_DIR)/pony-lsp pony-lsp
-
-$(BUILD_DIR)/pony-lsp:
-	$(MAKE) -C ..
+$(BUILD_DIR):
+	mkdir -p $(BUILD_DIR)
 
 clean:
-	rm -rf dist $(BUILD_DIR)
-
+	rm -rf dist build
 
 .PHONY: clean
diff --git a/README.md b/README.md
index 4903c5b..72531b1 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,48 @@
 # Pony Extension for Visual Studio Code
 
-## How to Build
+## Build it
 
 ```sh
-# compile the code
+# install dependencies
 npm install
+
+# compile the code
 npm run compile
+
 # build the package
-vsce package "${VERSION}"
-# uninstall any previously installed packages
-code --uninstall-extension undefined_publisher.pony-lsp
-# install the package
-code --install-extension "pony-lsp-${VERSION}.vsix"
+npm run vsce package
+```
+
+Alternatively run `make`!
+
+## Install it
+
+```sh
+# uninstall any previously installed extensions
+code --uninstall-extension ponylang.pony
+
+# install the newly-built package
+code --install-extension "pony-${VERSION}.vsix"
+```
+
+## Configure the Language Server
+
+### Prerequisites
+
+Install `pony-lsp` and [`ponyc`](https://github.com/ponylang/ponyc) and ensure they're on your PATH. For example:
+
+```sh
+brew install ponyc
+```
+
+The extension will show an error if `pony-lsp` is not found.
+
+### Configuration
+
+**`pony.ponyStdLibPath`**: The file path to the Pony standard library. If set, prepended to `PONYPATH`.
+
+```json
+{
+  "pony.ponyStdLibPath": "/usr/local/lib/ponyc/0.60.5/packages"
+}
diff --git a/VERSION b/VERSION
index 77d6f4c..0d91a54 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.0.0
+0.3.0
diff --git a/package.json b/package.json
index 7315482..663b4c7 100644
--- a/package.json
+++ b/package.json
@@ -1,14 +1,20 @@
 {
-  "name": "pony-lsp",
-  "description": "Ponylang Language Server",
-  "license": "MIT",
-  "version": "0.58.4",
-  "categories": [],
-  "repository": "https://github.com/ponylang/pony-language-server",
+  "name": "pony",
+  "displayName": "Pony",
   "publisher": "ponylang",
-  "displayName": "Ponylang Language Server",
+  "description": "Pony language support for Visual Studio Code",
+  "version": "0.3.0",
+  "license": "BSD-2-Clause",
+  "keywords": [
+    "pony"
+  ],
+  "categories": [
+    "Formatters",
+    "Programming Languages"
+  ],
+  "repository": "github:ponylang/vscode-extension",
   "engines": {
-    "vscode": "^1.75.0"
+    "vscode": "^1.108.1"
   },
   "activationEvents": [
     "onLanguage:pony"
@@ -29,6 +35,12 @@
           ],
           "default": "off",
           "description": "Traces the communication between VS Code and the Pony language server."
+        },
+        "pony.ponyStdLibPath": {
+          "scope": "window",
+          "type": "string",
+          "default": "",
+          "description": "Path to the Pony standard library packages directory. If not set, pony-lsp will try to auto-detect it."
         }
       }
     },
@@ -59,7 +71,8 @@
   "scripts": {
     "vscode:prepublish": "webpack --mode production",
     "compile": "webpack --mode none",
-    "watch": "webpack --mode none --watch"
+    "watch": "webpack --mode none --watch",
+    "vsce": "vsce"
   },
   "devDependencies": {
     "@types/bluebird": "^3.5.32",
@@ -67,6 +80,7 @@
     "@types/node": "^16.18.93",
     "@types/vscode": "^1.75.0",
     "@types/which": "^2.0.1",
+    "@vscode/vsce": "^3.7.1",
     "ts-loader": "^9.5.1",
     "typescript": "^4.8.4",
     "webpack": "^5.94.0",
diff --git a/src/extension.ts b/src/extension.ts
index cac4d5b..9e04113 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -4,9 +4,8 @@
 // git tag --sort=-creatordate
 
 import { ExtensionContext, window, StatusBarAlignment, StatusBarItem, workspace, OutputChannel } from 'vscode';
-
+import { execSync } from 'child_process';
 import {
-  ExecutableOptions,
   LanguageClient,
   LanguageClientOptions,
   ServerOptions,
@@ -16,22 +15,59 @@ import {
 let client: LanguageClient;
 let outputChannel: OutputChannel;
 
+function checkPonyLspExists(): boolean {
+  try {
+    const command = process.platform === 'win32' ? 'where pony-lsp' : 'which pony-lsp';
+    execSync(command, { stdio: 'pipe' });
+    return true;
+  } catch (error) {
+    return false;
+  }
+}
+
 export async function activate(context: ExtensionContext) {
   outputChannel = window.createOutputChannel("Pony Language Server");
 
-  let exe = context.asAbsolutePath("pony-lsp");
+  // Check if pony-lsp is available on PATH
+  if (!checkPonyLspExists()) {
+    const errorMessage = 'pony-lsp not found on PATH. Please install pony-lsp and ensure it is available in your system PATH.';
+    window.showErrorMessage(errorMessage);
+    outputChannel.appendLine(`ERROR: ${errorMessage}`);
+    showPony(false);
+    return;
+  }
+
   showPony(true);
+
+  // Get configuration
+  const config = workspace.getConfiguration('pony');
+  const ponyStdLibPath = config.get<string>('ponyStdLibPath', '');
+
+  // Prepare environment variables
+  const env = { ...process.env };
+
+  // Set or append to PONYPATH
+  if (ponyStdLibPath) {
+    if (env.PONYPATH) {
+      const pathSeparator = process.platform === 'win32' ? ';' : ':';
+      env.PONYPATH = `${ponyStdLibPath}${pathSeparator}${env.PONYPATH}`;
+      outputChannel.appendLine(`Prepending to PONYPATH: ${ponyStdLibPath}`);
+      outputChannel.appendLine(`Full PONYPATH: ${env.PONYPATH}`);
+    } else {
+      env.PONYPATH = ponyStdLibPath;
+      outputChannel.appendLine(`Setting PONYPATH: ${ponyStdLibPath}`);
+    }
+  } else if (env.PONYPATH) {
+    outputChannel.appendLine(`Using existing PONYPATH: ${env.PONYPATH}`);
+  }
+
   // If the extension is launched in debug mode then the debug server options are used
   // Otherwise the run options are used
   let serverOptions: ServerOptions = {
-    command: exe,
+    command: "pony-lsp",
     args: ["stdio"],
     transport: TransportKind.stdio,
-    options: {
-      env: {
-        "PONYPATH": context.asAbsolutePath("packages"),
-      }
-    }
+    options: { env }
   };
 
   // Options to control the language client

jairo-caro-ag and others added 22 commits January 7, 2023 12:28
* Prepare preparing a release

* Fix some vulns in js dependencies
* Properly set textDocumentSync properties of the serverCapabilities

in order to make the LSP work in neovim

* Add release notes

* Add publisher to vscode extension package.json

as demanded by vsce, the extension packaging and publishing tool
…ongs to

* Use loaded packages from compilation result, not packages listed in corral.json files

otherwise we miss out on nested packages.

TODO: also allow stdlib packages, which are outside of the current workspace.

* Ensure the lsp finds documents in all its compiled packages

not just in ones being contained within the workspace

* Update webpack to a safe version
npm audit fix

Co-authored-by: iacore <noreply+gpg-stub@1a-insec.net>
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 1, 2026
@orien orien force-pushed the merge-pony-language-server branch from 3b84f31 to 0c31ee0 Compare February 1, 2026 13:02
Makefile Outdated
@@ -0,0 +1,36 @@
PONY_VERSION := 0.58.4
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This contains stuff for the lsp. We definitely don't want to bring that over.

@@ -0,0 +1,78 @@
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a lot of this looks incorrect at this point.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's just a straight copy of the code at this point.

There's still plenty of configuration updates and testing needed before this PR will come out of draft.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A copy of the client_vscode directory, minus the client_vscode/packages directory - just to be clear.

@SeanTAllen
Copy link
Copy Markdown
Member

FYI, this will all get squashed down to a single commit.

If there are specific people who should be mentioned in the commit for "prior work", please let me know so they can be put in.

@orien
Copy link
Copy Markdown
Member Author

orien commented Feb 1, 2026

FYI, this will all get squashed down to a single commit.

If there are specific people who should be mentioned in the commit for "prior work", please let me know so they can be put in.

I think that's fine. GitHub should include all the commit authors in the default squash commit message.

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
let serverOptions: ServerOptions = {
command: "pony-lsp",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run pony-lsp as found on the path. Previously, pony-lsp was packaged in the extension.

Comment on lines +39 to +44
"pony.ponyStdLibPath": {
"scope": "window",
"type": "string",
"default": "",
"description": "Path to the Pony standard library packages directory. If not set, pony-lsp will try to auto-detect it."
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pony-lsp needs the Pony standard library on the PONYPATH. Create an configuration option for Visual Studio Code users to specify the path to their ponyc installation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the lsp not updated to search for the standard library the same as ponyc?

is this for "if I can't find the lsp, tell me where it is?"

Copy link
Copy Markdown
Member Author

@orien orien Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is "if the LSP can't find the standard library, specify where it is".

I'm not familiar with the specifics of that change though. @mfelsche?

On my system the LSP cannot find the standard library. It raises errors like this:

[Debug - 19:09:06] done compiling /Users/orien/src/orien/ponyc/tools/pony-lsp/test/workspace
[Trace - 19:09:06] Received notification 'window/logMessage'.
Params: {
    "message": "Compilation failed with 1 errors",
    "type": 5
}
[Debug - 19:09:06] Compilation failed with 1 errors
[Trace - 19:09:06] Received notification 'window/logMessage'.
Params: {
    "message": "ERROR: couldn't locate this path in file builtin",
    "type": 5
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that needs to be implemented in the LSP. I'll post the ponyc logic in a while.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic in question is in

https://github.com/ponylang/ponyc/blob/8adfa80ccebc44b2ba03218228950abdb78995ff/src/libponyc/pkg/package.c#L698

which is from "add_pony_installation_dir":

https://github.com/ponylang/ponyc/blob/8adfa80ccebc44b2ba03218228950abdb78995ff/src/libponyc/pkg/package.c#L658

It can be called from: package_init_lib

which i added to do what pony-lsp needs for ponydoc that is stalled. you can see it in:

bool ponydoc_init(pass_opt_t* options, const char* pony_installation) in ponydoc.c

@orien orien marked this pull request as ready for review February 2, 2026 13:03
@SeanTAllen
Copy link
Copy Markdown
Member

@orien I take it from the change in status that this is ready for merging?

@orien
Copy link
Copy Markdown
Member Author

orien commented Feb 4, 2026

@SeanTAllen Yes, I think it's good to merge. I'm happy to address feedback though.

@SeanTAllen
Copy link
Copy Markdown
Member

I'm going to merge and if there is feedback, we can address that going forward.

@SeanTAllen SeanTAllen merged commit 7610a93 into ponylang:main Feb 4, 2026
14 checks passed
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Feb 4, 2026
@orien orien deleted the merge-pony-language-server branch February 4, 2026 21:34
@orien orien mentioned this pull request Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants