Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Getting started documentation #33

Merged
merged 3 commits into from
Dec 15, 2023

Conversation

angelozerr
Copy link
Contributor

@angelozerr angelozerr commented Dec 7, 2023

docs: Getting started documentation

Fixes #24

@angelozerr angelozerr added the documentation Improvements or additions to documentation label Dec 7, 2023
@angelozerr angelozerr self-assigned this Dec 7, 2023
@angelozerr angelozerr added this to the 0.0.1 milestone Dec 7, 2023
@angelozerr angelozerr force-pushed the getting_started branch 6 times, most recently from 0cf9ae8 to 63bafcb Compare December 9, 2023 16:45
@angelozerr angelozerr changed the title doc: Getting started documentation docs: Getting started documentation Dec 9, 2023
@angelozerr angelozerr force-pushed the getting_started branch 6 times, most recently from 1777a46 to 4b04b53 Compare December 11, 2023 09:40
@angelozerr angelozerr marked this pull request as ready for review December 11, 2023 09:41
@angelozerr angelozerr requested a review from fbricon December 11, 2023 09:41
@angelozerr angelozerr force-pushed the getting_started branch 2 times, most recently from 3ff3148 to 91cb6e4 Compare December 11, 2023 14:06
@angelozerr angelozerr marked this pull request as draft December 11, 2023 14:16
@angelozerr angelozerr force-pushed the getting_started branch 5 times, most recently from 1b91f64 to 92bc62b Compare December 11, 2023 16:58
@angelozerr angelozerr force-pushed the getting_started branch 2 times, most recently from 3b64430 to 3e50b1d Compare December 11, 2023 17:15
@angelozerr angelozerr marked this pull request as ready for review December 11, 2023 17:15
docs/DeveloperGuide.md Outdated Show resolved Hide resolved
docs/DeveloperGuide.md Outdated Show resolved Hide resolved
docs/DeveloperGuide.md Outdated Show resolved Hide resolved
docs/DeveloperGuide.md Outdated Show resolved Hide resolved
docs/DeveloperGuide.md Outdated Show resolved Hide resolved
docs/DeveloperGuide.md Outdated Show resolved Hide resolved
docs/DeveloperGuide.md Outdated Show resolved Hide resolved
docs/DeveloperGuide.md Outdated Show resolved Hide resolved
docs/DeveloperGuide.md Outdated Show resolved Hide resolved
docs/LSPSupport.md Outdated Show resolved Hide resolved
@angelozerr angelozerr force-pushed the getting_started branch 8 times, most recently from 45fab1b to 98385ef Compare December 14, 2023 13:29
Copy link
Contributor

@fbricon fbricon left a comment

Choose a reason for hiding this comment

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

Still need to check LSPSupport.md


### Exclude all LSP4J dependencies

LSP4IJ depends on [Eclipse LSP4J](https://github.com/eclipse-lsp4j/lsp4j) (Java binding for the [Language Server Protocol](https://microsoft.github.io/language-server-protocol) and the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol).). It uses a given version of LSPJ and their classes are loaded in the LSP4IJ plugin class loader.
Copy link
Contributor

Choose a reason for hiding this comment

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

It provides its own version of LSP4J and its classes are loaded in the LSP4IJ plugin class loader.


LSP4IJ depends on [Eclipse LSP4J](https://github.com/eclipse-lsp4j/lsp4j) (Java binding for the [Language Server Protocol](https://microsoft.github.io/language-server-protocol) and the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol).). It uses a given version of LSPJ and their classes are loaded in the LSP4IJ plugin class loader.

Your IntelliJ Plugin should use `the same LSP4J classes than LSP4IJ` to avoid some `ClassCastException` errors. To do that you need to `exclude all LSP4J dependencies` from your plugin.
Copy link
Contributor

Choose a reason for hiding this comment

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

Your IntelliJ Plugin must not embed its own version of LSP4J, in order to avoid conflicts with the version provided by LSP4IJ. Failing to do see will result in ClassCastException errors to be thrown. Make sure that the LSP4J dependency in your plugin is either declared with a "runtimeOnly" scope or excluded entirely if it's included as a transitive dependency.


Your IntelliJ Plugin should use `the same LSP4J classes than LSP4IJ` to avoid some `ClassCastException` errors. To do that you need to `exclude all LSP4J dependencies` from your plugin.

Here a sample used in [Quarkus Tools](https://github.com/redhat-developer/intellij-quarkus) in [build.gradle.kts](https://github.com/redhat-developer/intellij-quarkus/blob/main/build.gradle.kts) to exclude LSP4J dependency from the [Qute Language Server](https://github.com/redhat-developer/quarkus-ls/tree/master/qute.ls) which have a dependency to LSP4J:
Copy link
Contributor

Choose a reason for hiding this comment

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

to exclude the LSP4J dependency from the Qute Language Server.

Comment on lines 119 to 144
## LanguageServerFactory

Create an implementation of [LanguageServerFactory](https://github.com/redhat-developer/lsp4ij/blob/main/src/main/java/com/redhat/devtools/lsp4ij/LanguageServerFactory.java) to use your `my.language.server.MyLanguageServer`, `my.language.server.MyLanguageClient` and defines a custom LanguageServer API if you need:

```java
package my.language.server;

import com.intellij.openapi.project.Project;
import com.redhat.devtools.lsp4ij.LanguageServerFactory;
import com.redhat.devtools.lsp4ij.client.LanguageClientImpl;
import com.redhat.devtools.lsp4ij.server.StreamConnectionProvider;
import org.jetbrains.annotations.NotNull;

public class MyLanguageServerFactory implements LanguageServerFactory {

@Override
public @NotNull StreamConnectionProvider createConnectionProvider(@NotNull Project project) {
return new MyLanguageServer(project);
}

@Override
public @NotNull LanguageClientImpl createLanguageClient(@NotNull Project project) {
return new MyLanguageClient(project);
}
}
```
Copy link
Contributor

Choose a reason for hiding this comment

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

move below L37


## Add specific IJ features

When it is possible, LSP4IJ declare the IJ feature with `any` language.
Copy link
Contributor

Choose a reason for hiding this comment

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

LSP4IJ binds IJ features to any language.

Comment on lines 258 to 269
<codeInsight.inlayProvider
language="MyLanguage"
implementationClass="com.redhat.devtools.lsp4ij.operations.codelens.LSPCodelensInlayProvider"/>
```

* `textDocument/inlayHint`:

```xml
<codeInsight.inlayProvider
language="MyLanguage"
implementationClass="com.redhat.devtools.lsp4ij.operations.codelens.LSPInlayHintInlayProvider"/>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

this should not be necessary anymore right?


![LSP console](./images/LSPConsole.png)

When language server is started, several action like stopping the language server or copy the command which starts the language servers are available:
Copy link
Contributor

Choose a reason for hiding this comment

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

several actions

@fbricon fbricon force-pushed the getting_started branch 2 times, most recently from 2f2b43c to ab5e0f2 Compare December 15, 2023 16:45
@angelozerr angelozerr merged commit c114384 into redhat-developer:main Dec 15, 2023
6 checks passed
@angelozerr
Copy link
Contributor Author

Thanks so much @fbricon for your great review!

@angelozerr angelozerr mentioned this pull request May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting started documentation
2 participants