Skip to content

feat: Implement automated installation for user-defined language servers - #1047

Merged
angelozerr merged 1 commit into
redhat-developer:mainfrom
angelozerr:installer_json
May 23, 2025
Merged

angelozerr merged 1 commit into
redhat-developer:mainfrom
angelozerr:installer_json

Conversation

@angelozerr

@angelozerr angelozerr commented May 18, 2025 •

Copy link
Copy Markdown
Contributor

feat: Implement automated installation for user-defined language servers

Fixes #999

This PR starts working but it requires a lot of improvement. The PR adds now an Installer tab:

image

The main idea is to declare with JSON the steps to check installation and install the server (but I repeat me it is a draft for the moment). step can be:

  • exec : to execute a command (ex : where node for windows and which node for other OS)
  • showMessage to show message with some buttons which execute an another step.
  • openUri to open a website uri (not already implemented)
  • download to download some language server (not already implemented)
  • ref to reference an another step (not already implemented)
  • each step can declare onFail to execute an another step when step fails.

Here the sample with typescript-language-server:

{
  "id": "typescript-language-server-installer",
  "name": "Install and verify TypeScript Language Server",
  "steps": [
    {
      "ref": "#check-node-runtime"
    },
    {
      "ref": "#check-typescript"
    },
    {
      "exec": {
        "name": "Check typescript-language-server",
        "command": {
          "windows": "where typescript-language-server",
          "default": "which typescript-language-server"
        },
        "onFail": {
          "showMessage": {
            "name": "typescript-language-server is not installed. How to do you want to install it?",
            "actions": [
              {
                "exec": {
                  "name": "Globally",
                  "command": {
                    "windows": ["npm.cmd", "install", "-g", "typescript-language-server"],
                    "default": ["npm", "install", "-g", "typescript-language-server"]
                  }
                }
              },
              {
                "openUrl": {
                  "name": "Visit typescript-language-server GitHub",
                  "url": "https://github.com/typescript-language-server/typescript-language-server"
                }
              }
            ]
          }
        }
      }
    }
  ]
}

When you click on Launch Installation, it execute steps:. You can see that in the right console and for this installer it show a message to install Globally the ls:

image

When you click on Globally it execute the npm install:

image

@angelozerr

Copy link
Copy Markdown
Contributor Author

@rcjsuen could you test this PR (please note that it is not finished) by installing the zip https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-the-ci-builds and give me a lot of feedbacks:

  • do you like the idea?
  • what do you think about the JSON syntax?
  • give me any idea to improve it this installer support.

Thanks!

@angelozerr
angelozerr force-pushed the installer_json branch 7 times, most recently from eb047c6 to ec0eb2d Compare May 20, 2025 09:39

@rcjsuen rcjsuen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rcjsuen could you test this PR (please note that it is not finished) by installing the zip https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-the-ci-builds and give me a lot of feedbacks

Hi @angelozerr, I have installed the plugin from this build.

  1. I tried the Docker Language Server first. It has no installation option but the link is still there. Clicking on the link does nothing and did not produce an error message. Is the expectation that all language servers have an installation option or should we disable this page if the JSON file is empty and/or malformed?
  2. I can click the install button in the "New Language Server" dialog and then errors start appearing behind everything. This seems counterintuitive.
image
  1. After installing the TypeScript Language Server the toast notification stays up for a while. I would have expected it to disappear immediately/faster after clicking on the "Globally" hyperlink button.
  2. Horizontal scrolling is terrible. Could we add a "Copy" button somewhere so that I can copy and paste the terminal output somewhere for me to read more easily? Or maybe a way to "open the message as a file"? Consider taking the terminal output and then a) putting the content into a temporary file and then b) opening it as a read-only buffer/file in JetBrains? Or maybe JetBrains can just let you open a byte[] or String? I don't know.
image
  1. As openUrl is not implemented yet I did not test that.
  2. As for the JSON schema, I don't really have a strong opinion either way. Instead of { "exec": { "command": ... } } you could consider doing { "type": "exec", "args": { ... } } and then you can do the same for { "type": "openUrl", "args": { ... } } and have everything have type and args. It's not the end of the world which way you end up taking. We should just make sure it is reasonably extensible I think.

public boolean run(@NotNull InstallerContext context) {
Ref<StepAction> selectedAction = new Ref<>();
Notification notification = new Notification(ServerMessageHandler.LSP_WINDOW_SHOW_MESSAGE_GROUP_ID,
"Install error",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

image

We might want to make this message title configurable. I clicked "Launch installation" and I get an "Install error" message telling me it's not installed. It doesn't make sense in this case for it to be an error because I purposely clicked on "Launch installation". I know it is not installed and that is why I am trying to install it.

Comment on lines +55 to +59
context.printError("✗ " + output.getStderr());
return false;
}

context.print("✓ " + output.getStdout());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How is JetBrains support for emojis in terminals? Maybe we could consider using ✅ and ❌ to make it clearer at a glance? Alternatively, adding the words like "Success" or "Failure" might help. I find these unicode checkmarks and X marks a little small myself.

@rcjsuen

rcjsuen commented May 20, 2025

Copy link
Copy Markdown
Contributor

I also noticed it seems to be spawning background tasks that "never end".

image image

@angelozerr

Copy link
Copy Markdown
Contributor Author

@rcjsuen thanks for your feedback. All your feedbacks show that the current PR is very bad, but it is normal because it is not finished.

I would like just to have feedback from the general idea. Do you like the idea?

I have changed the JSON descriptor and now we have a check and run section. It will help when I will integrate this JSON installer when language server will start.

Please be patient and let me provide a more stable PR.

@angelozerr

Copy link
Copy Markdown
Contributor Author

@rcjsuen could you test this PR (please note that it is not finished) by installing the zip https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-the-ci-builds and give me a lot of feedbacks

Hi @angelozerr, I have installed the plugin from this build.

  1. I tried the Docker Language Server first. It has no installation option but the link is still there. Clicking on the link does nothing and did not produce an error message. Is the expectation that all language servers have an installation option or should we disable this page if the JSON file is empty and/or malformed?

Yes sure we should disable it, but it is not the hard part :) For Docker Language Serve, I expect that you do a contribution when PR will be merged.

  1. I can click the install button in the "New Language Server" dialog and then errors start appearing behind everything. This seems counterintuitive.

Indeed I should take care about that.

image 3. After installing the TypeScript Language Server the toast notification stays up for a while. I would have expected it to disappear immediately/faster after clicking on the "Globally" hyperlink button.

Indeed, it is not implemented. For now I am working on download support.

  1. Horizontal scrolling is terrible. Could we add a "Copy" button somewhere so that I can copy and paste the terminal output somewhere for me to read more easily? Or maybe a way to "open the message as a file"? Consider taking the terminal output and then a) putting the content into a temporary file and then b) opening it as a read-only buffer/file in JetBrains? Or maybe JetBrains can just let you open a byte[] or String? I don't know.

I don't know, I have implemented very quickly this console. I wanted to have traces.

image 5. As `openUrl` is not implemented yet I did not test that.

Indeed

  1. As for the JSON schema, I don't really have a strong opinion either way. Instead of { "exec": { "command": ... } } you could consider doing { "type": "exec", "args": { ... } } and then you can do the same for { "type": "openUrl", "args": { ... } } and have everything have type and args. It's not the end of the world which way you end up taking. We should just make sure it is reasonably extensible I think.

I had started with type idea, but it is more verbose and for JSON Schema I think it is impossible to manage that.

@rcjsuen

rcjsuen commented May 20, 2025

Copy link
Copy Markdown
Contributor

I would like just to have feedback from the general idea. Do you like the idea?

Yes, sorry, I guess I did not answer that question itself now that I look back at what I wrote. :P

I think the idea is good and should be easy for people to implement. In the worst/hard cases language server developers can at least just use openUrl to point users to a webpage with more detailed instructions if desired.

I wonder about the UX if a separate modal dialog could be used so users can slowly advance/proceed through the process like a regular installer (like wizards in Eclipse).

@angelozerr

Copy link
Copy Markdown
Contributor Author

I would like just to have feedback from the general idea. Do you like the idea?

Yes, sorry, I guess I did not answer that question itself now that I look back at what I wrote. :P

I think the idea is good and should be easy for people to implement. In the worst/hard cases language server developers can at least just use openUrl to point users to a webpage with more detailed instructions if desired.

I wonder about the UX if a separate modal dialog could be used so users can slowly advance/proceed through the process like a regular installer (like wizards in Eclipse).

I think it is a bad idea to block the UI (vscode for instance avoid doing that). More this installer will be used when language server will be started (ex: when user will open a file which is associated to a language server). Perhaps we could manage modal UI in the future, but for now I would like to try to cover installer for all existing templates.

Let's go step by step.

@rcjsuen

rcjsuen commented May 20, 2025

Copy link
Copy Markdown
Contributor

I think it is a bad idea to block the UI (vscode for instance avoid doing that). More this installer will be used when language server will be started (ex: when user will open a file which is associated to a language server).

Okay, yeah, if you're thinking of initializing the process when the user opens a file then I agree that a blocking UI would not be good. Makes sense to me.

@angelozerr
angelozerr force-pushed the installer_json branch 3 times, most recently from 7529f83 to c4c988d Compare May 20, 2025 20:36
@angelozerr
angelozerr force-pushed the installer_json branch 2 times, most recently from 3cabb4b to 80b0226 Compare May 21, 2025 07:22
@angelozerr
angelozerr force-pushed the installer_json branch 6 times, most recently from 5fba311 to 77bd85c Compare May 22, 2025 10:00
@angelozerr
angelozerr force-pushed the installer_json branch 7 times, most recently from 493a7df to 5eeb6e7 Compare May 23, 2025 08:04
@angelozerr
angelozerr force-pushed the installer_json branch 3 times, most recently from 0e6183d to ec88e56 Compare May 23, 2025 13:26
@angelozerr
angelozerr marked this pull request as ready for review May 23, 2025 13:27
@angelozerr
angelozerr merged commit 1e0ad11 into redhat-developer:main May 23, 2025
@angelozerr

angelozerr commented May 23, 2025 •

Copy link
Copy Markdown
Contributor Author

@rcjsuen even if it is not perfect, I decided to merge the PR.

Once https://github.com/redhat-developer/lsp4ij/actions/runs/15211836313 will be finished you will able to install nighty. I suggest that you see https://github.com/redhat-developer/lsp4ij/blob/main/src/main/resources/templates/typescript-language-server/installer.json to contribuet with your installer.

You will see that it is very simple and there is no dialog message.

It is possible to have a showMessage dialog but there were too many problems (like you have seen with task which doesn't stop).

My main goal was to provide an installer which is working. It should work with rust, clangd, typescript. I will implement installer.json for other language server later.

Please not that this installer is working with also with DAP server. For instance of you want to debuh JS with https://github.com/redhat-developer/lsp4ij/blob/main/docs/dap/user-defined-dap/vscode-js-debug.md, now you will not need to download yourself the vscode-js-debug zip and not to update the DAP server command. It would work out of the box.

If you have time, please test rust and clangd since installer depends on OS.

For the moment there is no doc, you can read smart-data-lake/sdl-lsp#19 (comment)

I know that it is not perfect, don't hesitate to create any issues to improve this declarative installer.

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.

Implement automated installation for user-defined language servers

2 participants