/intellij-lsp-server

Exposes IntelliJ IDEA features through the Language Server Protocol.

Primary LanguageKotlinMIT LicenseMIT

intellij-lsp-server AppVeyor Build Status Travis CI Build Status

A plugin for IntelliJ IDEA that embeds a Language Server Protocol server, allowing other editors to use IntelliJ's features.

Requirements

  • IntelliJ IDEA 2018.1.1
    • Due to the way the plugin interacts with internal APIs, there currently isn't support for other versions of IDEA. If you're trying to use the plugin with Android Studio, note that the exact same Android support also exists in 2018.1.1.

Caveats

  • Alpha-quality, and probably really unstable.
  • Java and Kotlin are currently supported.
  • Editing in both IDEA and the LSP client at the same time isn't supported currently.
  • The server should work across any LSP client, but some nonstandard features (like using IntelliJ to build and run projects) are only implemented in the Emacs client.

Features

Code completion with snippet parameters

Snippet feature is provided by company-lsp.

Code completion with snippet parameters

Symbol usage highlighting

Highlights read/write usage.

Symbol usage highlighting

Find usages

Find usages

Go to definition

Can also find super method if available.

Go to definition

Go to implementation

Go to implementation

Diagnostics

Sideline view is provided by lsp-ui.

Diagnostics

Kotlin support

Kotlin support

Feature list

Name Method Emacs function
Workspace Symbols workspace/symbol ✔️ xref-find-apropos
Execute Command workspace/executeCommand ✔️
Diagnostics textDocument/publishDiagnostics ✔️ Used by lsp-ui.
Completion textDocument/completion ✔️ complete-symbol
Hover textDocument/hover ✔️
Signature Help textDocument/signatureHelp
Goto Definition textDocument/definition ✔️ xref-find-definitions
Goto Type Definition textDocument/typeDefinition ✔️ lsp-goto-type-definition
Goto Implementation textDocument/implementation ✔️ lsp-goto-implementation
Find References textDocument/references ✔️ xref-find-references
Document Highlights textDocument/documentHighlight ✔️
Document Symbols textDocument/documentSymbol ✔️ imenu (with lsp-imenu)
Code Action textDocument/codeAction
Code Lens textDocument/codeLens ✔️ lsp-intellij-run-at-point
Document Formatting textDocument/formatting ✔️ lsp-format-buffer
Document Range Formatting textDocument/rangeFormatting ✔️ indent-region
Document on Type Formatting textDocument/onTypeFormatting
Rename textDocument/rename

Nonstandard features

Name Method Emacs function
Get Run Configurations idea/runConfigurations ↩️
Build Project idea/buildProject ↩️ lsp-intellij-build-project
Run Project idea/runProject ↩️ lsp-intellij-run-project
Indexing Started idea/indexStarted ⬅️
Indexing Ended idea/indexEnded ⬅️
Build Messages idea/buildMessages ⬅️
Build Finished idea/buildFinished ⬅️

Commands

Name Command Emacs function
Open Project Structure openProjectStructure lsp-intellij-open-project-structure
Open Run/Debug Configurations openRunConfigurations lsp-intellij-open-run-configurations
Toggle IDEA Editor Window toggleFrameVisibility lsp-intellij-toggle-frame-visibility

Installation

Trying it out

Run ./gradlew runIde in the repository's top level to open a testing instance of IDEA.

Installing the plugin

Run ./gradlew clean buildPlugin in the repository's top level to create the plugin distribution. In IDEA, go to File -> Settings... -> Plugins -> Install plugin from disk... and select the .zip file that was output inside build/distributions.

Usage

The server will start automatically on TCP port 8080 when the IDE is loaded. You can configure the project SDK inside IDEA before connecting your client or execute the Open Project Structure command in the client (lsp-intellij-open-project-structure in Emacs) to open the Project Structure window remotely.

To use the server with Emacs/Spacemacs, see the lsp-intellij repository.

Rationale

  • I didn't like the latency of eclim. eclim-mode in emacs has to start a new process to get results from the eclim daemon, which takes about 5 seconds per command on my Windows system.
  • The Eclipse Java language server doesn't support Java 7, but projects using it are supported in the latest IDEA.
  • Support for eclim on Windows has been removed.
  • Developer usage of Eclipse itself has fallen over the years.
  • The exact same server concept has already existed in the form of intellivim, but it supports Vim only through a custom protocol.