eclipse-lsp4e / eclipse-lsp4e/lsp4e

LSPClientFeatures support

Open
#1,419 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
85
Forks
69
Avg merge
8h 33m
Merged PRs (30d)
6

Description

As LSP4E seems very active, I would like to share a feature I’ve implemented in LSP4IJ that provides an extremely simple way to customize LSP server integration and to cleanly check server capabilities.

You can find the LSP client features API here:
https://github.com/redhat-developer/lsp4ij/blob/main/docs/LSPApi.md

This API is very powerful because it allows you to customize almost anything in a clean and structured way. For example, you can disable specific LSP features, override labels returned by the language server, etc.

If a plugin wants to integrate a language server that provides formatting and needs to expose custom UI preferences—for instance, to configure tabSize—it simply has to register a custom LSPClientFeatures with a custom LSPFormattingFeature and override getTabSize so that it retrieves the tab size from the plugin’s UI settings.

If the language server needs to support WSL, the plugin can override URI building to translate WSL paths and generate the correct URI expected by the server.

Each feature implements an isSupported(PsiFile file) method, which relies on server capabilities (both static and dynamic). The codebase is very clear: for example, if you want to see how codelens capability detection is implemented, you can look at LSPCodeLensFeature#isSupported. This method can be overridden if a plugin wants to provide UI settings to enable or disable codelens for a specific language server.

The isSupported method relies on capability registries such as:
https://github.com/redhat-developer/lsp4ij/blob/main/src/main/java/com/redhat/devtools/lsp4ij/server/capabilities/CodeLensCapabilityRegistry.java

These registries extend abstract classes that implement full capability checking according to the LSP specification (documentSelector, filters, etc.), for example:
https://github.com/redhat-developer/lsp4ij/blob/6f41f6d22a7146f31e0218cb459513abd5dc16d3/src/main/java/com/redhat/devtools/lsp4ij/server/capabilities/TextDocumentServerCapabilityRegistry.java#L134

If you like this design (many IntelliJ plugins appreciate this feature), I believe you could reuse a significant part of the code and adapt it for LSP4E.

I simply wanted to share this LSP client features mechanism from LSP4IJ.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the LSP4IJ LSPApi.md and the referenced LSPClientFeatures.java, LSPFormattingFeature.java, LSPCodeLensFeature#isSupported, and capability registry classes. Then inspect the corresponding LSP4E client-feature and capability integration points, if present. Done requires a defined adaptation plan and agreement on which APIs and capabilities LSP4E should support.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.