Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Commit cac8e5f

Browse files
committed
Add LSP4IJ installer article
Signed-off-by: azerr <azerr@redhat.com>
1 parent 7836843 commit cac8e5f

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
slug: lsp4ij-installer
3+
title: Install Language Server / Debug Adapter server in one click
4+
authors: [angelozerr]
5+
tags: [lsp, intellij, lsp4ij, dap]
6+
---
7+
8+
LSP4IJ provides free DAP and LSP support for JetBrains IDE. DAP and LSP servers can be registered via an extension point so they can be integrated into an IntelliJ plugin.
9+
10+
But if you don't have the skills to do this, LSP4IJ allows you to register your LSP/DAP servers using the LSP/DAP server creation dialogs. The server description is stored in several JSON files that allow you to export/import the server into a template and easily share it with your team. This is called a user-defined server.
11+
12+
This feature has existed since the beginning of the LSP4IJ project, but one of the points that hadn't been addressed was server installation, which can be tedious. LSP4IJ 0.14.0 now provides the ability to automatically install an LSP/DAP server, allowing you to benefit from a language server with a single click.
13+
14+
Here is a demo with Rust:
15+
16+
![Install rust-analyzer](./assets/lsp4ij-installer/rust-analyzer-install.gif)
17+
18+
The same thing exists for DAP servers.
19+
20+
Here is a demo with VSCode JS Debug:
21+
22+
![Install VSCode JS Debug](./assets/lsp4ij-installer/vscode-js-debug-install.gif)
23+
24+
# What does it mean to install an LSP/DAP server?
25+
26+
Installing an LSP/DAP server generally requires the following steps:
27+
28+
* Checking and installing a runtime (Java, Node, Go, etc.) or not. To check for instance if node is installed. You can
29+
execute the following command on Windows OS:
30+
31+
```
32+
where node
33+
```
34+
35+
and the following command on other OS
36+
37+
```
38+
which node
39+
```
40+
41+
If the server is an executable, this step is not required.
42+
* Downloading the server using tools like npm or via a given URL. Some servers are downloadable via the GitHub releases page or Maven Central.
43+
* Extracting the downloaded file if it's a zip, tar, etc.
44+
* Granting execute permissions to the extracted server file
45+
* Updating the server startup command to reference the downloaded server file
46+
47+
All those steps are boring and adjusting command can takes some times.
48+
49+
# LSP4IJ installer
50+
51+
LSP4PIJ provide an API to [install LSP server](https://github.com/redhat-developer/lsp4ij/blob/main/docs/LSPApi.md#language-server-installer)
52+
and DAP server which are executed when server is started. Here a sample to install a language server:
53+
54+
```java
55+
package my.language.server;
56+
57+
import com.intellij.openapi.progress.ProgressIndicator;
58+
import com.intellij.openapi.progress.ProgressManager;
59+
import com.redhat.devtools.lsp4ij.installation.LanguageServerInstallerBase;
60+
import org.jetbrains.annotations.NotNull;
61+
62+
/**
63+
* A custom implementation of the {@link LanguageServerInstallerBase} class for installing a language server.
64+
* <p>
65+
* This class provides the logic to check if the language server is installed and performs the actual installation process
66+
* in steps, updating the progress indicator accordingly.
67+
*/
68+
public class MyLanguageServerInstaller extends LanguageServerInstallerBase {
69+
70+
/**
71+
* Checks if the language server is installed.
72+
* <p>
73+
* This implementation returns {@code true} to indicate the server is installed, but you should modify it to check
74+
* the actual installation state of your language server.
75+
*
76+
* @return true if the server is installed, false otherwise.
77+
*/
78+
@Override
79+
protected boolean checkServerInstalled(@NotNull ProgressIndicator indicator) {
80+
// check here if your language server is correctly installed
81+
progress("Checking if the language server is installed...", indicator);
82+
// Check if user has canceled the server installer task
83+
ProgressManager.checkCanceled();
84+
return true;
85+
}
86+
87+
/**
88+
* Installs the language server in steps, updating the progress indicator during the process.
89+
* <p>
90+
* This implementation provides two installation steps. You can modify this method to match the actual installation
91+
* steps for your language server.
92+
*
93+
* @param indicator the {@link ProgressIndicator} to update the installation progress.
94+
* @throws Exception if an error occurs during the installation process.
95+
*/
96+
@Override
97+
protected void install(@NotNull ProgressIndicator indicator) throws Exception {
98+
// process installation of step 1: downloading server components
99+
progress("Downloading server components...", 0.25, indicator);
100+
// Check if user has canceled the server installer task
101+
ProgressManager.checkCanceled();
102+
103+
// process installation of step 2: configuring server
104+
progress("Configuring server...", 0.5, indicator);
105+
// Check if user has canceled the server installer task
106+
ProgressManager.checkCanceled();
107+
108+
// process installation of step 3: finalizing installation
109+
progress("Finalizing installation...", 0.75, indicator);
110+
// Check if user has canceled the server installer task
111+
ProgressManager.checkCanceled();
112+
113+
// process installation of step 4: installation complete
114+
progress("Installation complete!", 1.0, indicator);
115+
// Check if user has canceled the server installer task
116+
ProgressManager.checkCanceled();
117+
}
118+
}
119+
```
120+
121+
This installer is implemented with Java code and can be used when language server is integrated inside an InteliJ plugin.
122+
123+
The rust demo which create the rust-analyzer language server and install it is fully declarative and are described
124+
with several JSON files
2.45 MB
Loading

0 commit comments

Comments
 (0)