Oni: Integrate Java language server

Created on 29 Jun 2017  路  18Comments  路  Source: onivim/oni

There is a support for LSP for Java on https://github.com/eclipse/eclipse.jdt.ls

It's already used on https://github.com/redhat-developer/vscode-java

Just to keep a note, since when finding some time I will help with this and #385

enhancement help wanted language-integration

Most helpful comment

Finally I did make this work on the last version. Just need to follow the steps above. 馃槃

@bryphe Now we have Java support on Oni. I will update the docs. 鈽曪笍

All 18 comments

Thanks @adelarsq for logging the issue! Looks like Java wasn't tracked before - this would be great to integrate with. I know @keforbes has a lot of Java experience too.

Just to keep a note, since when finding some time I will help with this and #385

Awesome, that would be great! There are starting to be several examples of LSP integration:

  • vim\core\oni-plugin-python
  • vim\core\oni-plugin-golang
  • vim\core\oni-plugin-csharp

And unless there are bugs in our LSP Client, or there is extra behavior, the plugins tend to be pretty small:

const activate = (Oni) => {

    const command = Oni.configuration.getValue("python.langServerCommand", "pyls")

    const serverOptions = {
        command,
    }

    const getInitializationOptionsAsync = (filePath) => {
        return Promise.resolve({
            clientName: "python",
            rootPath: "file:///" + filePath
        })
    }

    const client = Oni.createLanguageClient(serverOptions, getInitializationOptionsAsync)
}

module.exports = {
    activate
}

Since I like adding scope-creep to features I'm not working on 馃槅, would it be possible to configure any arbitrary language-server implementation from config.js? It seems like it really only involves a command to execute and potentially args to send to that command. If the current plugins are primarily boilerplate code it seems like we could build this on the fly with parameters provided in the config. I mean, config.js is just a json object, we can add more nesting if needed.

@extr0py, let me know if I'm way off-base here, I don't know what all it takes to provide each aspect of a lanuage server (goto definition, formatting, syntax highlighting, completion) so it may require more than just a nested object of flags (goto:true, completion:false) to configure.

EDIT: I guess what I'm thinking is:

"oni.languageserver.java" = {
   "name": "Java",
   "extension": "*.java",
   "provider": "myfunjavalanguageserver --hardcoded_args --file ${filename_placeholder}",
   "features": {
         "goto_def": true,
         "syntaxHighlighting": true,
         "formatting": false,
         "completion": true
    }
}

Let me know if I'm crazy.

Sounds like a great idea! For simple LSPs (which most are) that definitely seems sufficient. That would help generalize for now and we could implement more specific behavior later. It means we technically can support any LSP, and if there are more interesting pieces that need to be added, it could always be expanded out into a plugin.

Let me know if I'm crazy

Haha, not crazy at all! I'm a big fan of doing the minimum work to enable a feature, getting feedback, and then refining... but sometimes I need a reminder 馃槈 Thanks for the suggestion! I think this will be the next LSP piece I focus on after the ReasonML integration - #389 .

Was the wrong issue linked in 33c0350? It doesn't look like that commit is related to java language servers (or language servers at all).

It's actually correct - I'm splitting up the change and including some refactoring of the language service. This was just a prepatory refactoring (I'll be using the typed onBufferEnter and onBufferLeave events in the config-driven language service), and I'm focusing on having a config-driven way to pick up language servers with reasonable defaults.

Sorry for the confusion. I am actively working on the LSP issues (and Java support 馃槃 ) though, thanks for checking!

Cool, sorry for the false alarm :hushed:.

--

I'm really liking Oni. Actual vim inside an IDE is a killer feature, and java support would be awesome.

FYI, the java language server support should be possible now by configuring it: https://github.com/onivim/oni/wiki/Language-Support

This one looks like a pain to install... but there are some good tips in this thread:
https://www.reddit.com/r/neovim/comments/79vbnz/java_lsp/

Would be interested if anyone gets it working!

@bryphe I'm trying to make it work again. It's almost working I think, but shows this message:

\dev\oni\node_modules\vscode-jsonrpc\lib\messageReader.js:68 Uncaught Error: Message header must separate key and value using :
    at C:\dev\oni\node_modules\vscode-jsonrpc\lib\messageReader.js:68
    at Array.forEach (<anonymous>)
    at MessageBuffer.tryReadHeaders (C:\dev\oni\node_modules\vscode-jsonrpc\lib\messageReader.js:65)
    at StreamMessageReader.onData (C:\dev\oni\node_modules\vscode-jsonrpc\lib\messageReader.js:194)
    at Socket.<anonymous> (C:\dev\oni\node_modules\vscode-jsonrpc\lib\messageReader.js:185)
    at emitOne (events.js:115)
    at Socket.emit (events.js:210)
    at addChunk (_stream_readable.js:252)
    at readableAddChunk (_stream_readable.js:239)
    at Socket.Readable.push (_stream_readable.js:197)

Any hint about what can be?

@adelarsq seems this was closed in error would you like me to re-open it if your still working on this

@Akin909 yes, I'm trying to make this work. Was possible to make it work with vim-lsc, so I think that is a little change

Still trying to figure out what can be done to solve this issue. How to see the message header sent to the language server?

The Java language server can be found on this link. I did put on the C:\dev\jdt-language-server-latest folder.

Also, to make easier execute was created a bat file (C:\dev\jdt-language-server-latest\java-language-server.bat):

cd C:\dev\jdt-language-server-latest & java -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.protocol=true -Dlog.level=ALL -noverify -Xmx1G -jar ./plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar -configuration ./config_win -data %1

%1 receives the root path from the Java project.

For the oni config I'm using:

"language.java.languageServer.command": "java-language-server.bat",
"language.java.languageServer.arguments": [],
"language.java.languageServer.rootFiles": ["pom.xml"],
"language.java.languageServer.configuration": {},

Appears that the headers array is wrong:
image

Finally I did make this work on the last version. Just need to follow the steps above. 馃槃

@bryphe Now we have Java support on Oni. I will update the docs. 鈽曪笍

@adelarsq , that's awesome news! 馃帀 Thanks for the update! Really appreciate you updating the docs!

I updated the docs. 馃摐 馃槃
Was waiting the pull https://github.com/Microsoft/vscode-languageserver-node/pull/343 land on jsonrpc. No longer necessary

Added support for Bash, Dart, Docker, Haskell, Lua and Ruby. I'm trying to make Erlang and Elixir to work.

@adelarsq Using this and it's great! Is it possible to get it to do auto imports? Pretty essential for java.

@olivercf currently, Oni doesn't support that but its something we are aware of and want to add.

There is an issue about it at #1593 (with a bounty on it I think). Its about first adding the functionality, then hooking it up for the built in typescript server. Though if its added for one thing, it shouldn't be too hard to extend it.

Was this page helpful?
0 / 5 - 0 ratings