/ideals

Turns IntelliJ IDEA into a generic LSP server

Primary LanguageJavaMIT LicenseMIT

Table of Contents
  1. Universal LSP server
  2. Requirements
  3. Caveats
  4. Feature list
  5. Usage
  6. Installation
  7. Contribute with us
  8. Contact

IdeaLS (IDEA Language Server)

An Intellij IDEA plugin that is intended to turn IntelliJ IDEA into an LSP server and deliver the power of IDEA's language support to LSP clients.

LSP is a protocol that allows decoupling the editor and the language support logic, so you can (theoretically) use any editor supporting LSP client functionality (like Visual Studio Code, Sublime Text, Vim, Emacs, Eclipse, etc.) with any LSP server.

There are a lot of LSP servers with different feature sets for different languages. This one differs from the others in that it doesn't define its own language logic but rather translates LSP requests into IDEA API calls. So it does what your IDEA does, with the languages your IDEA supports, but with your favorite editor. If you are working on a multi-language project you don't need many language-specific LSP servers anymore. Just install IntelliJ IDEA with appropriate set of plugins and turn it into one LSP server for all the languages you need.

IdeaLS is designed to be as much language agnostic as possible. However, for a better user experience some parts are still dependent on language-specific API.

The project was heavily inspired by intellij-lsp-server

(back to top)

Requirements

  • IntelliJ IDEA (Community or Ultimate) 2022.2 or higher

(back to top)

Caveats

  • The project is in a very early stage and really unstable.
  • The server is tested with Visual Studio Code only.
  • There are conflicts with the Android plugin on startup, so you have to disable it in the IDEA.
  • There is A LOT of work yet to be done, please be indulgent.

(back to top)

Feature list

Name Method VSCode Action
Workspace Symbols workspace/symbol ✔️ Ctrl + T
Execute Command workspace/executeCommand
Diagnostics textDocument/publishDiagnostics ✔️ N/A
Completion textDocument/completion ✔️ Ctrl + Space
Hover textDocument/hover
Signature Help textDocument/signatureHelp
Goto Definition textDocument/definition ✔️ Ctrl + Left mouse click
Goto Type Definition textDocument/typeDefinition ✔️ Right mouse click -> Go to -> Type defintion
Goto Implementation textDocument/implementation
Find References textDocument/references ✔️ Right mouse click -> Go To -> References
Document Highlights textDocument/documentHighlight ✔️ Left mouse click on symbol
Document Symbols textDocument/documentSymbol ✔️ Ctrl + O
Code Action textDocument/codeAction ✔️ Ctrl + .
Code Lens textDocument/codeLens
Document Formatting textDocument/formatting ✔️ Ctrl + Shift + P -> Format Document
Document Range Formatting textDocument/rangeFormatting ✔️ Select text -> Ctrl + Shift + P -> Format Selection
Document on Type Formatting textDocument/onTypeFormatting ✔️ N/A
Rename textDocument/rename

(back to top)

Installation

Trying it out

Autoconfiguration of IDEA project is not implemented yet, So, before launching IDEA as a language server you have to start IDEA in normal mode and configure your project manually (setup SDK, modules, dependencies, install required plugins etc.). As a result the .idea directory should be present in the project root.

Run runIde gradle task to open a testing instance of IDEA. After that you will need to run the client extension, that is described in Running client section

Installing plugin

  1. Run :clean :buildPlugin gradle tasks to create the plugin distribution.
  2. In IDEA, go to File -> Plugins -> Install plugin from disk... and select the .zip file that was output inside build/distributions.

Running server

For running as language server IDEA must be configured to be executed in headless mode (no GUI). Add line -Djava.awt.headless=true into idea.vmoptions (can be found inside the bin directory in the IDEA installation root). (we're working on making this part less cumbersome)

Run idea lsp-server on Windows or idea.sh lsp-server on Unix.

Now server is working on 8989 port.

Running client

You need to build vscode extension, that is placed in client/vscode folder. Extension building guide

In vscode go to Extensions -> Install from VSIX... and choose built extension.

Note, that you need to enable extension before, not after the server has started.

(back to top)

Contribute with us.

IdeaLS is an opensource product. We welcome everyone who wants to make it better. If you want to contribute with us, write @serganch in Telegram.

(back to top)

Contact

Sergey Anchipolevsky - @serganch

Project Link: https://github.com/serganch/ideals

(back to top)