The current implementation of LSP4IJ
does not yet fully adhere to the LSP (Language Server Protocol) specification. This section provides an overview of the supported LSP features for IntelliJ:
Current state of Base protocol support:
- ✅ $/cancelRequest.
- ✅ $/progress (see implementation details)
Current state of Text Document Synchronization support:
- ✅ textDocument/didOpen.
- ✅ textDocument/didChange.
- ✅ textDocument/didClose.
- ✅ textDocument/didSave.
- ❌ textDocument/willSave.
- ❌ textDocument/willSaveWaitUntil.
Notebooks are not supported.
Current state of Language Features support:
- ✅ textDocument/definition (see implementation details)
- ✅ textDocument/documentHighlight (see implementation details)
- ✅ textDocument/publishDiagnostics (see implementation details)
- ✅ textDocument/documentLink (see implementation details)
- ❌ documentLink/resolve.
- ✅ textDocument/hover (see implementation details)
- ✅ textDocument/codeLens (see implementation details)
- ✅ codeLens/resolve
- ❌ workspace/codeLens/refresh
- ✅ textDocument/inlayHint (see implementation details)
- ❌ inlayHint/resolve
- ✅ workspace/inlayHint/refresh
- ✅ textDocument/completion (see implementation details)
- ✅ completionItem/resolve (see implementation details)
- ✅ textDocument/signatureHelp (see implementation details)
- ✅ textDocument/publishDiagnostics (see implementation details)
- ✅ textDocument/codeAction (see implementation details)
- ✅ codeAction/resolve
- ✅ textDocument/documentColor (see implementation details)
- ❌ textDocument/colorPresentation.
- ✅ textDocument/declaration (see implementation details)
- ✅ textDocument/typeDefinition (see implementation details)
- ✅ textDocument/implementation (see implementation details)
- ✅ textDocument/references (see implementation details)
- ❌ textDocument/prepareCallHierarchy.
- ❌ textDocument/incomingCalls.
- ❌ textDocument/outgoingCalls.
- ❌ textDocument/prepareTypeHierarchy.
- ❌ typeHierarchy/supertypes.
- ✅ textDocument/foldingRange (see implementation details)
- ❌ textDocument/selectionRange.
- ❌ textDocument/documentSymbol.
- ❌ textDocument/semanticTokens.
- ❌ textDocument/inlineValue.
- ❌ workspace/inlineValue/refresh.
- ❌ textDocument/moniker.
- ❌ textDocument/pullDiagnostics.
- ✅ textDocument/formatting (see implementation details)
- ✅ textDocument/rangeFormatting (see implementation details).
- ❌ textDocument/onTypeFormatting.
- ✅ textDocument/prepareRename.
- ✅ textDocument/rename (see implementation details).
- ❌ textDocument/linkedEditingRange.
Current state of Workspace Features support:
- ✅ workspace/didChangeWatchedFiles.
- ✅ workspace/executeCommand.
- ✅ workspace/applyEdit.
- ❌ workspace/symbol.
- ❌ workspace/symbolResolve.
- ❌ workspace/configuration.
- ❌ workspace/workspaceFolders.
- ❌ workspace/didChangeWorkspaceFolders.
- ❌ workspace/willCreateFiles.
- ❌ workspace/didCreateFiles.
- ✅ workspace/willRenameFiles.
- ✅ workspace/didRenameFiles.
- ❌ workspace/willDeleteFiles.
- ❌ workspace/didDeleteFiles.
Current state of Window Features support
- ✅ window/showMessage. (see implementation details)
- ✅ window/showMessageRequest (see implementation details)
- ✅ window/logMessage (see implementation details)
- ✅ window/showDocument.
- ❌ telemetry/event.
$/progress is implemented with Background Tasks
.
Here a sample with Eclipse JDT Language Server:
textDocument/definition is implemented via the
gotoDeclarationHandler
extension point. As this extension point supports any
language, it works out-of-the-box.
It is also called via Find Usages to show definitions.
The textDocument/references is consumed with:
- the
Navigate / LSP Reference(s)
global menu. - or with the
Go To/ LSP Reference(s)
editor menu.
This menu action either opens the reference in a popup or navigates to the reference if there are several references:
textDocument/references is used too via Find Usages to show references.
The textDocument/implementation is consumed with:
- the
Navigate / LSP Implementation(s)
global menu. - or with the
Go To/ LSP Implementation(s)
editor menu.
This menu action either opens the implementation in a popup or navigates to the implementation if there are several implementations:
textDocument/implementation is too used via Find Usages to show implementations.
The textDocument/typeDefinition is consumed with:
- the
Navigate / LSP Type Definition(s)
global menu. - or with the
Go To/ Type Definition(s)
editor menu.
This menu action either opens the type definition in a popup or navigates to the type definition if there are several type definitions:
textDocument/typeDefinition is used too via Find Usages to show Type definitions.
The textDocument/declaration is consumed with:
- the
Navigate / LSP Declaration(s)
global menu. - or with the
Go To/ Declaration(s)
editor menu.
This menu action either opens the declaration in a popup or navigates to the declaration if there are several declarations:
textDocument/declaration is used too via Find Usages to show declarations.
textDocument/documentHighlight is implemented via the
highlightUsagesHandlerFactory
extension point. As this extension point supports any
language, it works out-of-the-box.
Here is an example with the Qute language server, highlighting item variables:
textDocument/documentLink is implemented via:
- an
externalAnnotator
extension point, to display adocumentLink
with an hyperlink renderer. - a
gotoDeclarationHandler
extension point, to open the file of thedocumentLink
.`
As those extension points support any
language, textDocument/documentLink
works out-of-the-box.
Here is an example with the Qute language server, displaying an include
template with an hyperlink renderer (Ctrl+Click opens the document link):
textDocument/hover is implemented with platform.backend.documentation.targetProvider
extension point to support any language and textDocument/hover
works out-of-the-box.
Here is an example with the Qute language server showing documentation while hovering over an include
section:
textDocument/codeLens is implemented with the codeInsight.codeVisionProvider
extension point.
As LSP4IJ registers LSPCodeLensProvider
for all languages associated with a language server, it works out-of-the-box.
Here is an example with the Qute language server, which shows REST services URL with codeLens:
textDocument/inlayHint is implemented with the codeInsight.inlayProvider
extension point.
LSP4IJ registers LSPInlayHintProvider for all languages associated with a language server with
LSPInlayHintProvidersFactory, so it works out-of-the-box.
Here is an example with the Qute language server showing the parameter's Java type as inlay hint:
textDocument/documentColor is implemented with the codeInsight.inlayProvider
extension point.
LSP4IJ registers LSPColorProvider for all languages associated with a language server with
LSPInlayHintProvidersFactory, so it works out-of-the-box.
Here is an example with the CSS language server showing the color's declaration with a colored square:
textDocument/completion is implemented with
LSPCompletionContributor class
declared with the
completion.contributor
extension point. As this extension point supports any
language, it works out-of-the-box.
Here is an example with the Qute language server showing method completion:
The completionItem/resolve request is implemented to resolve:
- the
documentation
property of a completionItem.
Here a sample with TypeScript Language Server completion item which resolves and shows documentation
when the completion item is selected:
- the
detail
property of a completionItem.
Here a sample with TypeScript Language Server completion item which resolves and shows detail
when the completion item is selected:
- the
additionalTextEdits
property of a completionItem.
textDocument/signatureHelp is implemented with
the codeInsight.parameterInfo
extension point. By default, LSP4IJ registers the codeInsight.parameterInfo
with
LSPParameterInfoHandler class for TEXT
and textmate
languages:
<!-- LSP textDocument/signatureHelp -->
<codeInsight.parameterInfo
id="LSPParameterInfoHandlerForTEXT"
language="TEXT"
implementationClass="com.redhat.devtools.lsp4ij.features.signatureHelp.LSPParameterInfoHandler"/>
<codeInsight.parameterInfo
id="LSPParameterInfoHandlerForTextMate"
language="textmate"
implementationClass="com.redhat.devtools.lsp4ij.features.signatureHelp.LSPParameterInfoHandler"/>
If you use another language, you will have to declare codeInsight.parameterInfo
with your language.
Here is an example with the TypeScript Language Server showing signature help:
textDocument/foldingRange is implemented with
the lang.foldingBuilder
extension point. By default, LSP4IJ registers the lang.foldingBuilder
with
LSPFoldingRangeBuilder class for TEXT
and textmate
languages:
<!-- LSP textDocument/folding -->
<lang.foldingBuilder id="LSPFoldingBuilderForText"
language="TEXT"
implementationClass="com.redhat.devtools.lsp4ij.features.foldingRange.LSPFoldingRangeBuilder"
order="first"/>
<lang.foldingBuilder id="LSPFoldingBuilderForTextMate"
language="textmate"
implementationClass="com.redhat.devtools.lsp4ij.features.foldingRange.LSPFoldingRangeBuilder"
order="first"/>
If you use another language, you will have to declare lang.foldingBuilder
with your language.
Here is an example with the Go Language Server showing folding:
textDocument/publishDiagnostics is implemented with an externalAnnotator
extension point. As this extension point supports any
language, it works out-of-the-box.
Here is an example with the Qute language server reporting errors:
Here is an example featuring the Clojure LSP, which offers code actions:
- Quickfix code action (at the top): This type of code action is facilitated by registering a
quick fix within the IntelliJ annotation
. - Other code actions such as refactoring (at the bottom): These kinds of code actions are handled using
Intentions
.
For the last type of code action, you can enable/disable them using the Intentions / Language Server
preference setting.
textDocument/rename is implemented with LSPRenameHandler class
declared with the renameHandler
extension point.
Here is an example with the TypeScript Language Server showing rename of function name:
textDocument/formatting / textDocument/rangeFormatting are implemented with
LSPFormattingOnlyService /
LSPFormattingAndRangeBothService with the formattingService
extension point.
window/showMessage supports Markdown messages and clickable links.
Here is an example with Rust Analyzer reporting an error:
{
"type": 1,
"message": "Failed to discover workspace.\nConsider adding the `Cargo.toml` of the workspace to the [`linkedProjects`](https://rust-analyzer.github.io/manual.html#rust-analyzer.linkedProjects) setting.\n\nFailed to load workspaces."
}
is rendered as a Balloon
notification:
You can change the notification behavior of LSP/window/showMessage
by using the standard UI Notifications
preferences :
window/showMessageRequest is supported.
Here is an example with Scala Language Server (MetaLS) reporting a message request:
{
"actions": [
{
"title": "Create .scalafmt.conf"
},
{
"title": "Run anyway"
},
{
"title": "Not now"
}
],
"type": 1,
"message": "No .scalafmt.conf file detected. How would you like to proceed:"
}
is rendered as a Sticky balloon
notification:
You can change the notification behavior of LSP/window/showMessageRequest
by using the standard UI Notifications
preferences :