Skip to content

WIP: Initial API design#2

Draft
ono-max wants to merge 1 commit into
Shopify:mainfrom
ono-max:extract-code-from-ruby-lsp
Draft

WIP: Initial API design#2
ono-max wants to merge 1 commit into
Shopify:mainfrom
ono-max:extract-code-from-ruby-lsp

Conversation

@ono-max

@ono-max ono-max commented Sep 22, 2025

Copy link
Copy Markdown

Source code change summary

  • The following files were extracted from ruby-lsp without any modifications
    • src/ruby/**
    • src/workspaceChannel.ts
  • src/ruby.ts was extracted from ruby-lsp, and modified to adapt to the API.

Extension Settings

{
    "extensionDependencies": [
        "shopify.ruby-environments"
    ],
    "dependencies": {
        "@shopify/ruby-environments": "..."
    },
}

API

API Specification: https://github.com/Shopify/ruby-environments/blob/6254b3c216921a28737ebbe748238f4ba89b6782/rubyEnvironmentsApi/src/index.ts

Here is the example:

// Import the API
import { RubyEnvironments } from '@shopify/ruby-environments';

const rubyEnvApi: RubyEnvironmentsApi = await RubyEnvironmentsApi.getApi();

const rubyEnv = await rubyEnvApi.getEnvironment(vscode.workspace.workspaceFolders[0]);

This API is inspired by the following projects:

How to test this code

  1. Install both VS Code extension and NPM module as follows:
  1. Modify package.json in your testing VS Code extension as follows:
{
    "extensionDependencies": [
        "shopify.ruby-environments"
    ],
    "dependencies": {
        "@shopify/ruby-environments": "..."
    },
}
  1. Add the following lines to your testing VS Code extension.
import { RubyEnvironments } from '@shopify/ruby-environments';
const rubyEnvApi: RubyEnvironmentsApi = await RubyEnvironmentsApi.getApi();
const rubyEnv = await rubyEnvApi.getEnvironment(vscode.workspace.workspaceFolders[0]!);
console.log(rubyEnv);

@ono-max

ono-max commented Sep 22, 2025

Copy link
Copy Markdown
Author

I have signed the CLA!

@ono-max ono-max force-pushed the extract-code-from-ruby-lsp branch 18 times, most recently from c0d4a74 to f2f1f48 Compare September 23, 2025 13:48
@rafaelfranca

Copy link
Copy Markdown
Member

I don't like this API. I'd prefer to use closer to the one used in the python environments extension

https://github.com/microsoft/vscode-python/blob/cbcf5e17341c7e0f5c71c16c3262852f643d48b8/src/client/pythonEnvironments/api.ts

Something like:

import { RubyEnvironments } from '@shopify/ruby-environments';
api = new RubyEnvironments(vscode.workspace.workspaceFolders[0]!);
await api.activate();
const rubyEnv = await api.getEnvironment();
console.log(rubyEnv);

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.

2 participants