Skip to content

Code completion and navigation for Kotlin#9428

Open
jtulach wants to merge 3 commits into
apache:masterfrom
jtulach:KotlinLsp
Open

Code completion and navigation for Kotlin#9428
jtulach wants to merge 3 commits into
apache:masterfrom
jtulach:KotlinLsp

Conversation

@jtulach

@jtulach jtulach commented Jun 5, 2026

Copy link
Copy Markdown
Contributor
  • I am starting to work on a project with huge Kotlin code base
  • I'd like to use my IDE to help me navigate and modify that code base
  • Hence I am suggesting extension of existing NetBeans Kotlin support (as provided by Syntax coloring for .kt files #1228)
  • with that I am able to navigate and see code completion in .kt files of my project

@jtulach jtulach self-assigned this Jun 5, 2026
@jtulach jtulach added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Kotlin labels Jun 5, 2026
@jtulach

jtulach commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

I am using kt-mvvm project as a test that the new Kotlin LSP support works. Here are the highlights:

Hint to install LSP Server

Restarted the IDE and then asked for code completion:

CC works!

Ctrl+Mouse click navigation works as well. Now I can be happy Kotlin developer!

@matthiasblaesing

matthiasblaesing commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

I wanted to get a first glance of this, but installation fails with a non descript error. I build from this branch and ran with "ant tryme". I opened an android project with kotlin files. In the kotlin files I see the "Install Kotlin LSP Server" entry. When I choose that I see a progressbar dialog for a short time and then:

grafik

There were no entries in the message log about this.

I then looked into the plugin-in dialog. There is no entry for the kotlin LSP Plugin, shouldn't that be visible there?

The URL in the external file worked (I suspected, that download is only possible when authenticated to github, but curl happily starts downloading after telling it to follow redirects).

@jtulach jtulach requested a review from matthiasblaesing June 8, 2026 04:11
@jtulach

jtulach commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for trying @matthiasblaesing...

I then looked into the plugin-in dialog. There is no entry for the kotlin LSP Plugin, shouldn't that be visible there?

The URL in the external file worked (I suspected, that download is only possible when authenticated to github, but curl happily starts downloading after telling it to follow redirects).

... I don't think authentication is needed. Certainly my JVM isn't authenticated to GitHub and I am able to successfully:

netbeans$ git log | head -n3
commit 0b08fd4428ae9c4790b3d1a2ae741cfa41ece186
Author: Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Date:   Sun Jun 7 15:29:29 2026 +0200
netbeans$ rm -rf *; git checkout -f .; JAVA_HOME=/jdk-21/ ant build
netbeans$ JAVA_HOME=/jdk-21 ant tryme

and after clicking "Install Kotlin LSP" the download info appears in the log file:

[exec] INFO [org.netbeans.modules.autoupdate.services.InstallSupportImpl]: 
Trying external URL: 
https://github.com/fwcd/kotlin-language-server/releases/download/1.3.13/server.zip

After restart (I'll try to remove the need for a restart), the code completion & co. seems to work.

@jtulach

jtulach commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

I'll try to remove the need for a restart

I am trying, but so far I am getting:

org.netbeans.api.autoupdate.OperationException[ENABLE]: could not add Kotlin LSP[org.netbeans.libs.kotlin.lsp/1.3.13] for activation
	at org.netbeans.modules.autoupdate.ui.ModuleInstallerSupport.installPlugins(ModuleInstallerSupport.java:199)
	at org.netbeans.modules.autoupdate.ui.GuiPluginInstallerImpl.install(GuiPluginInstallerImpl.java:48)
	at org.netbeans.api.autoupdate.PluginInstaller.install(PluginInstaller.java:123)
[catch] at org.netbeans.api.autoupdate.PluginInstaller.install(PluginInstaller.java:70)
	at org.netbeans.modules.kotlin.editor.lsp.UnconfiguredHint$ConfigureLSPServer.implement(UnconfiguredHint.java:99)
	at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:811)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1370)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1981)

@neilcsmith-net

neilcsmith-net commented Jun 8, 2026

Copy link
Copy Markdown
Member

Thanks for working on this. Would love to see Kotlin support included. However, it might be a concern that that language server is marked deprecated? Particularly because it also mentions using internal APIs of the compiler. OTOH, the "official" alternative is currently partly closed source. It gives me some thought that this might be better distributed as a plugin until this settles down. Depends how easy it might be to upgrade this to the alternative in future if/when desired?

@Saljack

Saljack commented Jun 8, 2026

Copy link
Copy Markdown

FYI fwcd Kotlin LSP is deprecated and there is official Kotlin LSP from JetBrains https://github.com/Kotlin/kotlin-lsp . Unfortunately it is still alpha version. I tried to use both in Netbeans but I returned back to fwcd (mainly because our Kotlin code is pretty old).

@jtulach

jtulach commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for working on this. Would love to see Kotlin support included.

+1

However, it might be a concern that that language server is marked deprecated?

I see https://github.com/fwcd/kotlin-language-server page says:

Important

There is now an official language server, so this project can be considered deprecated.

This is what I get for trying to resurrect some old code. I should have done that years ago! However please note the wording. It is not "deprecated"! It may be "considered deprecated". That's a conditional surrender to superiority of Kotlin creator, not declaration of surrender.

official Kotlin LSP from JetBrains https://github.com/Kotlin/kotlin-lsp . Unfortunately it is still alpha version. I tried to use both in Netbeans but I returned back to fwcd

Another indicator fwcd isn't deprecated/useless. It seems to work fine with me.

It gives me some thought that this might be better distributed as a plugin until this settles down.
Depends how easy it might be to upgrade this to the alternative in future if/when desired?

Changing the server is just about packaging. Once people decide to use the official one, it is just a matter of packaging it. That's easy, but apparently neither me or @Saljack want to do that. We'd rather stick with fwcd in this PR.

@jtulach

jtulach commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

There are two parts of this PR:

  • changes in java/kotlin.editor to configure some LSP server
  • changes to plugin portal to offer a NetBeans module with LSP server for download

We want the java/kotlin.editor part to get in.

The other part (e.g. the org.netbeans.modules.kotlin.lsp module) could possibly (as suggested by Neil) could be a real NBM on update center. CCing @jkovalsky. However these parts are connected (via the module name) and maybe it is easier to get them in together - which is what this PR proposes right now.

@Saljack

Saljack commented Jun 9, 2026

Copy link
Copy Markdown

It is off-topic, but it can help other users to use Kotlin in Netbeans because there is a high chance they will find this PR. Here is how I configured Kotlin in Netbeans:
image

@matthiasblaesing

matthiasblaesing commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@Saljack want to do that. We'd rather stick with fwcd in this PR.

I think it is fine to do that now. I just needs to work 😃

@neilcsmith-net

Copy link
Copy Markdown
Member

Funnily enough, just needing to work is one of my concerns! Deprecated and useless are not synonymous, but that repo has open issues about not working on recent JDKs, and hasn't had a release in 18 months or an update in 12.

There is an active fork incidentally, at https://codeberg.org/winlogon/ktlsp Although no releases I can see as yet. Something else mentioned there is https://github.com/Hessesian/kmp-lsp

So, I'm a little wary of having a hardcoded link to something that might not work across our supported platforms, and also with a GitHub releases link, which while not requiring authentication are also not immutable by default.

I just think the plugin option is easier to push an update for in between IDE releases should we need to. OTOH, if released by us it would still require a vote, so perhaps not?! 😄

Also, while probably out of scope directly in this, it feels like that part of this could possibly be generic. We could potentially maintain a registry file with links and hashes for LSP server implementations across mime-types that the IDE could query?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Kotlin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants