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

Language Server Protocol client #629

Merged
merged 20 commits into from Sep 13, 2018

Conversation

Projects
None yet
6 participants
@jlahoda
Contributor

jlahoda commented Jul 8, 2018

This is a crude prototype of a Language Server Protocol client for NetBeans.

It currently supports:
-diagnostics from the server
-go-to-declaration
-code completion

It uses the Eclipse LSP4J (https://github.com/eclipse/lsp4j) to handle the protocol and to provide the model for the messages (I used to have a custom implementation of the protocol, but it seemed wasteful to maintain that).

There are currently two ways to use a server from the IDE:
-a module provides bindings for a particular language, starts and registers a LS. I have a crude prototype of such a module using KotlinLanguageServer, but not good enough to that publish, yet.
-the user starts the LS manually somehow, and then binds the IDE to the running LS.

To see the client in action using the latter approach, the following can be used:
-clone https://github.com/fwcd/KotlinLanguageServer
--build it (gradle install)
--unpack build/distributions/kotlin-language-server-0.1.1.zip somewhere
-clone https://github.com/jlahoda/nb-lsp-helpers
--build it (ant jar in run-lsp)
--go to run-lsp/dist and run: "java -jar run-lsp.jar /bin/kotlin-language-server"
-run NetBeans, be sure there are no files opened in the editor, use the search feature in the top right corner, type "Connect", select "Connect to Language Server" action. Fill in your project's root (e.g. the path to the checked-out KotlinLanguageServer), port is 9965, extensions "kt". In a while the IDE should connect to a the LS. Then open a kt file (from the specified project), and the above features should work.

@jlahoda jlahoda requested a review from geertjanw Jul 8, 2018

@Chris2011

This comment has been minimized.

Show comment
Hide comment
@Chris2011

Chris2011 Jul 9, 2018

Contributor

Only to let you know: https://issues.apache.org/jira/browse/NETBEANS-180 So this PR will resolve, more or less, this ticket.

Contributor

Chris2011 commented Jul 9, 2018

Only to let you know: https://issues.apache.org/jira/browse/NETBEANS-180 So this PR will resolve, more or less, this ticket.

@jtulach

Consider importing Eclipse OSGi bundles as OSGi bundles.

@timfel

This comment has been minimized.

Show comment
Hide comment
@timfel

timfel Jul 25, 2018

A few observations:

  • Go to symbol seems not to be implemented with the documentSymbol message
  • Custom lsp actions are not implemented, e.g. the codeLens or codeAction LSP messages

timfel commented Jul 25, 2018

A few observations:

  • Go to symbol seems not to be implemented with the documentSymbol message
  • Custom lsp actions are not implemented, e.g. the codeLens or codeAction LSP messages
@geertjanw

Sounds great, what needs to be done for a first release of this feature?

@JaroslavTulach

This comment has been minimized.

Show comment
Hide comment
@JaroslavTulach

JaroslavTulach Sep 11, 2018

Contributor

gson-2.7.jar is OSGi bundle. Please reuse it as OSGi bundle. Not as a wrapped module.

Contributor

JaroslavTulach commented on ide/c.google.gson/nbproject/project.xml in 0733bfa Sep 11, 2018

gson-2.7.jar is OSGi bundle. Please reuse it as OSGi bundle. Not as a wrapped module.

This comment has been minimized.

Show comment
Hide comment
@jlahoda

jlahoda Sep 11, 2018

Contributor
Contributor

jlahoda replied Sep 11, 2018

@JaroslavTulach

This comment has been minimized.

Show comment
Hide comment
@JaroslavTulach

JaroslavTulach Sep 11, 2018

Contributor

Reusing existing guava seems OK. On the other hand, com.google.guava:guava:21.0 is an OSGi bundle and it would be better to use it as OSGi bundle. At least in the future. Edit: turns out existing ide/c.google.guava is already an OSGi bundle.

Contributor

JaroslavTulach commented on ide/libs.lsp/nbproject/project.xml in 0733bfa Sep 11, 2018

Reusing existing guava seems OK. On the other hand, com.google.guava:guava:21.0 is an OSGi bundle and it would be better to use it as OSGi bundle. At least in the future. Edit: turns out existing ide/c.google.guava is already an OSGi bundle.

@JaroslavTulach

This comment has been minimized.

Show comment
Hide comment
@JaroslavTulach

JaroslavTulach Sep 11, 2018

Contributor

This should have been moved to a separate module. Right?

Contributor

JaroslavTulach commented on ide/libs.lsp/nbproject/project.xml in 0733bfa Sep 11, 2018

This should have been moved to a separate module. Right?

@JaroslavTulach

OSGi bundles would better be used as OSGi bundles, not as a wrapped JARs. Edit: turns out that except missing ide/c.google.gson/build.xml, it is already prepared as OSGi bundle.

@JaroslavTulach JaroslavTulach merged commit f2b7bd0 into apache:master Sep 13, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Chris2011

This comment has been minimized.

Show comment
Hide comment
@Chris2011

Chris2011 Oct 10, 2018

Contributor

How will syntax highlighting work? I mean how to get it from the LS @jlahoda?

Contributor

Chris2011 commented Oct 10, 2018

How will syntax highlighting work? I mean how to get it from the LS @jlahoda?

@geertjanw

This comment has been minimized.

Show comment
Hide comment
@geertjanw
Member

geertjanw commented Oct 10, 2018

Not supported yet by LSP: Microsoft/vscode-languageserver-node#367

@jlahoda

This comment has been minimized.

Show comment
Hide comment
@jlahoda

jlahoda Oct 10, 2018

Contributor

The simple answer is that the LSP does not support highlighting at this point. So no highlighting through the LSP. See for example:
eclipse/lsp4j#40

This may get into the protocol eventually, see:
Microsoft/vscode-languageserver-node#367

Contributor

jlahoda commented Oct 10, 2018

The simple answer is that the LSP does not support highlighting at this point. So no highlighting through the LSP. See for example:
eclipse/lsp4j#40

This may get into the protocol eventually, see:
Microsoft/vscode-languageserver-node#367

@Chris2011

This comment has been minimized.

Show comment
Hide comment
@Chris2011

Chris2011 Oct 10, 2018

Contributor

Ok, thx.

Contributor

Chris2011 commented Oct 10, 2018

Ok, thx.

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