Metals implements a Language Server Protocol extension called the "Decoration Protocol" to display non-editable text in the text editor.
The Decoration Protocol has several base data structures that are mostly derived from the VS Code API.
A "decoration" represents non-editable code that is displayed in the text editor alongside editable code. The GIF below demonstrates an example of green decorations that are formatted as comments, which contain the evaluated code.
Although decorations appear as text inside the editor, they can't be edited by the user. In the GIF above, observe that the decoration can optionally include a message that's displayed on mouse hover.
The Decoration Protocol is embedded inside the Language Server Protocol and consists of a single JSON-RPC notification.
The Decoration Protocol is only enabled when client declares support for the
protocol by adding an
decorationProvider: true field to the
initializationOptions during the
Depending on your editor, it may also allow for inline decorations. This is used
for features like showing implicit arguments and inferred types, both which are
user configuration settings that a user can toggle. However, in order for those
features to use decorations rather than just extra information in your hover,
your client also needs to declare that it's an
The decoration ranges did change notification is sent from the server to the client to notify that decorations have changes for a given text document.
PublishDecorationsParamsas defined below:
- v0.1.0: First release with basic support for worksheets.
MarkupContentto align with LSP 3.15