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

Support LSP4IJ, which is a third-party LSP server integration #437

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

koxudaxi
Copy link
Owner

@koxudaxi koxudaxi commented May 8, 2024

Related Issues: #415 (comment)

@koxudaxi koxudaxi marked this pull request as draft May 8, 2024 17:07
build.gradle.kts Outdated
@@ -27,6 +32,14 @@ dependencies {
compileOnly(libs.ini4j)
compileOnly(libs.kotlinxSerialization)
testImplementation(kotlin("test"))
// implementation("com.redhat.devtools:lsp4ij:0.10.0")
implementation("org.eclipse.lsp4mp:org.eclipse.lsp4mp.ls:0.10.0") {

Choose a reason for hiding this comment

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

You dont need lsp4mp which ptovide a microprofile ls and dont need qute ls

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thank you for your comment.
I just removed it.

Copy link

github-actions bot commented May 29, 2024

Qodana Community for JVM

30 new problems were found

Inspection name Severity Problems
Usage of API marked for removal 🔴 Failure 6
Unused symbol 🔶 Warning 7
Unused import directive 🔶 Warning 5
Control flow with empty body 🔶 Warning 2
Constructor parameter is never used as a property 🔶 Warning 1
Incorrect string capitalization 🔶 Warning 1
Usage of redundant or deprecated syntax or deprecated symbols 🔶 Warning 1
Class member can have 'private' visibility ◽️ Notice 3
Array property in data class ◽️ Notice 1
Const property naming convention ◽️ Notice 1
Package name does not match containing directory ◽️ Notice 1
Regular expression can be simplified ◽️ Notice 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2024.1.2
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

class RuffLsp4IntellijClient(val project: Project): RuffLspClient {
private val lspServer get() = RuffLanguageServerFactory().createConnectionProvider(project)
override fun start() {
lspServer.start()
Copy link
Owner Author

Choose a reason for hiding this comment

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

@angelozerr @fbricon
Can I start/stop the LSP server without an extension point?
I want to switch LSP server by using GUI settings.

Copy link

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thank you. Is it difficult to switch using code without using the UI? If not, we will have to change the implementation policy. I'm thinking of switching to the original Idea function from the settings.

Copy link

Choose a reason for hiding this comment

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

I'm sorry I'm not sure I understand your question

Choose a reason for hiding this comment

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

Can I start/stop the LSP server without an extension point?

Could you explain why you don't want to use the extension point to define your language server? I have the impression that you want to enable / disable with Java code (and not with LSP console menu actions) the language server, right?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Sorry for the poor explanation.

Currently the lsp functionality is optional and can be enabled by the user checking it in the settings.
The current implementation only starts the LSP functionality made by Jetbrains when this option is enabled.

Secondly, I consider LSP4IJ to be the second option implemented.
In other words, in addition to switching the current LSP functionality (server) on and off, I believe there should be the ability to switch between the JetBrains LSP functionality or LSP4IJ.
You can actually understand this by looking at the screenshots.

If it is difficult to switch on/off from the java code, we will consider dropping support for LSP made by JetBrains.
However, the LSP functionality in ruff is optional and unless you have the latest Ruff or ruff-lsp installed, you will not be able to use LSP, otherwise you will have to directly hit the ruff command without LSP to provide features such as inspection.
We also believe that it is necessary to restart the LSP server, e.g. after the installation of a package for each project. (e.g. if we do a pip install and install the latest version of ruff-lsp, we want the plugin to detect the update and restart the lsp function).

class RuffPackageManagerListener(project: Project) : PyPackageManager.Listener {
private val ruffConfigService = RuffConfigService.getInstance(project)
private val ruffCacheService = RuffCacheService.getInstance(project)
@Suppress("UnstableApiUsage")
private val lspServerManager = if (lspIsSupported) LspServerManager.getInstance(project) else null
override fun packagesRefreshed(sdk: Sdk) {
ruffConfigService.projectRuffExecutablePath = findRuffExecutableInSDK(sdk, false)?.absolutePath
ruffConfigService.projectRuffLspExecutablePath = findRuffExecutableInSDK(sdk, true)?.absolutePath
ruffCacheService.setVersion()
if (lspServerManager != null && ruffConfigService.useRuffLsp) {
try {
@Suppress("UnstableApiUsage")
lspServerManager.stopAndRestartIfNeeded(RuffLspServerSupportProvider::class.java)

image

Screenshot 2024-05-30 at 9 16 06

Copy link

Choose a reason for hiding this comment

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

Thanks for the explication. As your usecase could interest other people could you please create an issue in lsp4ij. Thanks.

Managing language server like start/stop disable/enable are doable since we do that internally but we need perhaps provide API to manage that.

Choose a reason for hiding this comment

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

@koxudaxi I created an issue at redhat-developer/lsp4ij#314 I will work on it and once I will some better idea I will fill my idea in the issue description. Please follow this issue

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.

None yet

3 participants