tensorchord / vscode-envd

vscode extension for envd
https://marketplace.visualstudio.com/items?itemName=tensorchord.vscode-envd
Apache License 2.0
2 stars 4 forks source link

proposal: next-generation envd vscode plugin #10

Open cutecutecat opened 1 year ago

cutecutecat commented 1 year ago

After make a survey of existing issues, I think there might be 4 parts that need to be implement:

I would show the details of each part below. It may take a couple of days fulfilling all parts of the proposal. Additional discussion is needed.

cutecutecat commented 1 year ago

About User-friendly UI

ref: https://github.com/tensorchord/envd/issues/931

Detail

Envd act like docker, the deploy of sidebar can be refered to https://code.visualstudio.com/docs/containers/overview

We can make a similar sidebar about environment according to docker image like this: image

List

However, there could be another view of arrangement, as we only need destroy, pause/resume and run command, and there might be not many environments: image

Summary

After discussion, we pick List as final sidebar show.

cutecutecat commented 1 year ago

About User Operation Optimization

ref: https://github.com/tensorchord/envd/issues/931

WE need to implement two level of Command:

Global Command

Global command will run at vscode command image

We will provide these commands:

Install/Upgrade Envd: use pip install --upgrade envd to install envd(need a configure pointing to exsting pip) Bootstrap Envd: call CommandBootstrap, initial envd and buildkit Clear Cache: call CommandPrune, clean cache of all

File Command

We add an Run icon at every build function of envd file. File command will run by right click of a envd file or click a icon.

image

We provide these commands:

Build environment: build a xxx.envd to environment Run environment: build a xxx.envd to environment and run it

User can choose which action is default by left click icon in configure, though both of them can be fetched in right click menu.

cutecutecat commented 1 year ago

About Syntax update and auto update

ref: https://github.com/tensorchord/envd-lsp/issues/7

vscode-lsp imports envd/api to extract syntax. The used version is v0.1.1, we should update it into v0.2.5 first of all.

https://github.com/tensorchord/envd-lsp/blob/5440364fb084f219beb635a4d99812240bdbdc49/go.mod#L7

Unbind envd-vscode and envd-lsp

Now, Lsp server is released together with envd-vscode plugin, with a fixed version. There are two reasons of why envd-vscode need to update:

That would make user confused for these two reason, we need to unbind these two module. envd-vscode will have no envd-lsp default module, and download and install it when vscode plugin is installed by user.

graph TD
m[compatible with] --> a[envd-lsp v1.0]
m[compatible with] --> b[envd-lsp v2.0]
m[compatible with] --> c[envd-lsp v3.0]

A[envd-vscode v1.0] --> m[compatible with]
B[envd-vscode v2.0] --> m[compatible with]
C[envd-vscode v3.0] --> m[compatible with]

Implement

We need to implement an auto update pipeline by 3 factor:

A is a simple dependabot. B could be a Github Action, when A trigers an PR, it would do these things:

sequenceDiagram
    participant S as Envd
    actor A as A[Dependency Bot]
    actor B as B[Release Bot]
    participant T as Envd-Lsp
    S->>A: Manual Release envd v1.0.0
    A->>T: Auto Update dependency v1.0.0
    B-->>T: Auto Release envd-lsp v1.0.0
    S->>A: Manual Release envd v1.1.0
    A->>T: Auto Update dependency v1.1.0
    B-->>T: Auto Release envd-lsp v1.2.0
    S->>A: Manual Release envd v1.2.0
    A->>T: Auto Update dependency v1.2.0
    B-->>T: Auto Release envd-lsp v1.2.0

ref:

cutecutecat commented 1 year ago

About Lsp server auto install and management

Now, Lsp server is released together with envd-vscode plugin, with a fixed version. We intend to make envd-vscode ability to mangage and install lsp server locally.

By description of Syntax update and auto update, we can infer that any released version of envd-vscode will have a equal version of envd-lsp. But when user want to use another version of envd and need to switch an older envd-lsp.

We provide there vscode commands for them: Install/Upgrade Lsp: update lsp version to latest, prompt when no lsp found. Switch version of Lsp: install a special version of lsp, prompt a version choose window

We provide these configure for them: lsp path: path of lsp server, will be overrided if Install/Upgrade Lsp and Switch version of Lsp succeed, change this can use a self-install lsp

sequenceDiagram
    actor U as User
    participant V as envd-vscode
    participant L as envd-lsp
    U->>V: Manual Install plugin first time
    V->>L: Have a existing version?(path/envd-lsp -v)
    L->>V: No(command not found)
    V->>U: Lsp not found. Want to install?
    U->>V: Click yes
    V->>L: Download latest lsp
    Note over V,L: Overwrite envd path configure
    V->>L: Have a existing version?(path/envd-lsp -v)
    L->>V: Ok
    V->>U: Report Lsp version
cutecutecat commented 1 year ago

Other improvement

Here is other improvement of priority/low. If there is enough time, we can make a research.

Auto insert tab/space when user input Enter

Python plugin support this feature.

13319d0f-2ce2-4c65-9b17-69fe9ee74817

Go to Definition

Some user may like right click Go to Definition for builtin functions in envd. image

We have a dependency of envd/api, we can point definition to it.

Include syntax support

Envd syntax analysis is provided by envd/api document comment. Unfortunately, these things not happens to include, they would have no hint at all.

For example, the tensorboard function in this graph image

Maybe we can add analysis of these including envd functions, as they are valid python code either.

Not sure if this is achievable, more research is needed

gaocegege commented 1 year ago

Thanks for your contribution! :tada: :+1:

I suggest filing a PR to envd like this https://github.com/tensorchord/envd/pull/303

Then we can discuss it with other community members there.