Replies: 6 comments 6 replies
-
I would like to run the Netbeans Java LS standalone as well. Any guidance/help would be greatly appreciated! The only other place I could find where this was discussed (without a complete solution) was https://www.reddit.com/r/netbeans/comments/rm5q1v/how_can_i_use_netbeans_java_language_server_in/ |
Beta Was this translation helpful? Give feedback.
-
Hi! I am also interested in having the chance to use Netbeans Java LSP with emacs (with lsp-java). Any guidence will be welcome. |
Beta Was this translation helpful? Give feedback.
-
I think the way to proceed, since the authors haven't replied yet, is to attach a debugger to the language, and do a comparison of what you'd expect it to do vs what it is actually doing. I might give it a shot sometime soon, I'm also interested in nbcode + eglot. |
Beta Was this translation helpful? Give feedback.
-
FWIW, I've been successfully investigating running nbcode in Eclipse IDE. /*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc.. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
package com.redhat.eclipseide.nbcode;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.util.List;
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
public class NBCodeStreamConnectionProvider extends ProcessStreamConnectionProvider {
final static int port = 9123; // currently static, should be made dynamic
private InputStream in;
private OutputStream out;
private Socket clientSocket;
public NBCodeStreamConnectionProvider() {
super(List.of("/home/mistria/Downloads/nbcode/bin/nbcode.sh", "--start-java-language-server=listen:" + port), "/home/mistria/Downloads/nbcode");
// super(List.of("/home/mistria/.vscode/extensions/oracle.oracle-java-1.0.0/nbcode/bin/nbcode.sh", "--userdir", "/home/mistria/sandbox/userdir", "--start-java-language-server=stdio"));
}
@Override
public void start() throws IOException {
super.start();
try {
Thread.sleep(3000); // give some time for LS to start
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.clientSocket = new Socket(InetAddress.getLocalHost(), port);
this.in = this.clientSocket.getInputStream();
this.out = this.clientSocket.getOutputStream();
}
@Override
public InputStream getInputStream() {
return this.in;
}
@Override
public OutputStream getOutputStream() {
return this.out;
}
@Override
public void stop() {
super.stop();
try {
this.clientSocket.close();
} catch (IOException ex) {
ex.printStackTrace();
}
this.clientSocket = null;
}
} I had to override the behavior for /*---------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc.. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
package com.redhat.eclipseide.nbcode;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.eclipse.lsp4e.LanguageClientImpl;
import org.eclipse.lsp4j.ConfigurationParams;
public class NBLanguageClient extends LanguageClientImpl {
@Override
public CompletableFuture<List<Object>> configuration(ConfigurationParams params) {
return CompletableFuture.completedFuture(List.of());
}
} I don't know yet if it's fixed in latest LSP4J and just nbcode missing a recent update; or if issue is still present in LSP4J (and should be reported there). HTH |
Beta Was this translation helpful? Give feedback.
-
Okay so by some stroke of luck, I was able to get it working. I tried messing around with the socket option as mentioned above (was able to get it working evnetually), but both (require 'eglot)
(defclass eglot-nbcode (eglot-lsp-server) ()
:documentation "nbcode specialization of `eglot-lsp-server'.")
(cl-defmethod eglot-initialization-options ((_s eglot-nbcode))
'(:nbcodeCapabilities
( :statusBarMessageSupport nil
:testResultsSupport nil
:showHtmlPageSupport nil
:wantsJavaSupport t
:wantsGroovySupport t )))
(defun eglot-java--init-ls (_interactive)
(cons 'eglot-nbcode
'("/home/karan/nbcode/bin/nbcode.sh"
"--start-java-language-server=stdio")))
(add-to-list 'eglot-server-programs '(java-ts-mode . eglot-java--init-ls)) This is all it took, although the |
Beta Was this translation helpful? Give feedback.
-
@Uthar (setq inhibit-startup-message t) ;Disable startup buffer
(menu-bar-mode -1)
(tool-bar-mode -1) ; Disable the toolbar
(scroll-bar-mode -1) ; Disable visible scrollbar
(load-theme 'tango-dark)
(setq make-backup-files nil) ; stop creating ~ files
(require 'project)
(require 'eglot)
(with-eval-after-load 'eglot
(rplacd (assoc '(java-mode java-ts-mode) eglot-server-programs)
'("/home/khaled/lsps/nbcode/bin/nbcode.sh" "--start-java-language-server=stdio"
:initializationOptions (:nbcodeCapabilities
(:statusBarMessageSupport nil
:testResultsSupport nil
:showHtmlPageSupport nil
:wantsJavaSupport t
:wantsGroovySupport t
)
)
)
)
)
(setq-default eglot-workspace-configuration
'(:netbeans.javadoc.load.timeout 10000
:netbeans.java.onSave.organizeImports :json-true))
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-refresh-contents)
(use-package company
:ensure t
)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages '(company)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
) I somehow knew it was the problem and tried to use company |
Beta Was this translation helpful? Give feedback.
-
I built the server using
ant
, now I'm trying to connect it with Eglot (LSP client for Emacs). But when I run thenbcode
script on my Ubuntu system, it only prints some warnings and the client can't connect to it. It looks like it's ignoring the stdin, but I don't know. I also tried using thenbcode.js
script with nodejs, but that had the same effect. This is with JDK17. With JDK8, I'm getting an error "java.lang.IllegalStateException: No NetigsoFramework found, is org.netbeans.core.netigso module enabled?", also when running thenbcode
shell script. With JDK11, It's a similar situation except there are no warnings as with 17. When I run the extension from vscode, it works, But I want to make it work with Eglot.Here's the log of what Eglot sends to the server, maybe something is missing?
test.txt
. Any ideas why it won't connect?
Update: Today I figured out that I need to pass the
--start-java-language-server=stdio
flag tonbcode
. But now, I am getting an exception when trying to initialize:Update 2:
The reason for the above was missing
:nbcodeCapabilities
ininitializationOptions
. I fixed it like this:Now one more issue occurs, when trying to complete a class name:
Update 3:
Here's the full communication between the client and the server for the completion error. The
nil
there looks worying...Update 4:
The above was due to missing workspace config, which the server expects: Fixed it like this:
Now the server connects, but returns empty responses on any action:
Example communication:
I will be grafetul for help making this work. Can anyone see something missing?
Beta Was this translation helpful? Give feedback.
All reactions