gtache / intellij-lsp

Plugin adding Language Server Protocol support for IntelliJ
Apache License 2.0
397 stars 48 forks source link

No more maintained

If anyone wants to take over this project, send me an email. In the meantime, it seems that JetBrains will support LSP with their new Fleet IDE.
Also check out lsp4intellij which was forked from this project.
There is a Kotlin branch which is a conversion of the master one, but it wasn't tested.

intellij-lsp

Plugin adding support for Language Server Protocol for IntelliJ since version 2018.2
This plugin should be compatible with any JetBrains IDE (tested successfully on IntelliJ, PyCharm and CLion)

Features

What is working (or should be but isn't tested) :
Requests to the server:

Client :

The plugin should integrate seamlessly with another plugin supporting a same language (e.g. Scala language server and Scala plugin). The plugin will simply delegate to the Scala plugin any features it already supports (for example, if the Scala plugin supports formatting, the LSP plugin won't ask the language server to format.) The reason is that the current specific plugins are much more powerful than the current language servers at the moment.
You have the possibility to force sending the requests by checking the "Always send requests" checkbox in the settings.

Concretely, what you can do with IntelliJ at the moment :

Add a Language Server

This plugin supports communicating with multiple and different language servers at the same time.
To add a supported language server, you can either create a plugin (see intellij-lsp-dotty) which extends this plugin and extend LanguageServerDefinition or instantiate a concrete subclass of it and register it, or simply go to IntelliJ/file/settings/Languages & Frameworks/Language Server Protocol and fill the required informations. You can specify multiple extensions for one server by separating them with a semicolon. (example : ts;js)
Note that the settings will always override a possible LSP plugin for the same file extension.
You can also configure the timeouts for the requests (if you see timeouts warning in the log for example), depending on your computer.
Settings:
Settings

Via a plugin (example with concrete subclass instantation):

class RustPreloadingActivity extends PreloadingActivity {

  override def preload(indicator: ProgressIndicator): Unit = {
    //Assume rls is on Path
    LanguageServerDefinition.register(new ExeLanguageServerDefinition("rs", "rls", Array()))
  }
}

With plugin.xml containing

<extensions defaultExtensionNs="com.intellij">
      <preloadingActivity implementation="com.github.gtache.lsp.rust.RustPreloadingActivity" id="com.github.gtache.lsp.rust.RustPreloadingActivity" />
  </extensions>
<depends>com.github.gtache.lsp</depends>

The current concrete classes are :

If you need/want to write an other implementation, you will need to at least implement the createConnectionProvider method, which instantiates and returns a StreamConnectionProvider (which can be basically anything as long as it gets you the input and output stream to the server). You can also implement custom logic in the start and stop methods of the server definition if needed.

Further extensions

You can add a custom LSPIconProvider to provide custom icons for the completion/symbols items or for the server status. You need to register an LSPIconProvider extension in your plugin.xml and implement the required methods (or delegate to the default provider).

FAQ