Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README #350

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
# Language Server Protocol types code generator
# Language Server Protocol types code generator & packages

This repository contains a Python implementation of [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) types and classes, and code generators for various languages.
This repository contains packages and tools to generate code for [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) types and classes.

It simplifies the creation of language servers for different programming languages by providing a robust and easy-to-use type generation system.

# Usage
➡️ For instructions on how to use the **code generator**, refer to the [Usage](#usage) section.

➡️ For instructions on existing **plugins and packages** for different languages, refer to the table in the [Existing packages/plugins](#existing-packagesplugins) section.

➡️ For instructions on how to **create additional plugins** to support more languages, refer to the [Contributing plugins](#contributing-plugins) section.

# Code Generator Usage

You will need a Python environment to run the generator. Here are the steps:

1. Create a Python environment: `python -m venv .venv`
> **Note**: Python 3.8 is the minimum supported version
2. Install this repo's tool: `python -m pip install git+https://github.com/microsoft/lsprotocol.git`
3. Run your plugin. For example: `python -m generator --plugin dotnet --output-dir ./code`
2. Activate the environment: `.venv\Scripts\activate` (Windows) or `source .venv/bin/activate` (Linux/macOS)
3. Install this repo's tool: `python -m pip install git+https://github.com/microsoft/lsprotocol.git`
4. Run your plugin. You can use the [command line](#command-line) or [Nox](#using-nox) to run the generator.

## Command line

Clone this repository and run `generator` as a Python module.

For example: `python -m generator --plugin dotnet --output-dir ./code`

```console
>python -m generator --help
usage: __main__.py [-h] [--model [MODEL [MODEL ...]]] --plugin PLUGIN
Expand Down Expand Up @@ -70,12 +79,13 @@ nox > Created plugin java.
nox > Session create_plugin was successful.
```

# Supported plugins
# Existing packages/plugins

Below is the list of plugins already created using this package.
Below is the list of plugins already created using this package, with their respective package links.

| Language | Plugin Module | Package | Status |
| -------- | ------------------------ | --------------------------------------------------------------------------------------------------- | ----------------- |
| Python | generator.plugins.python | [![PyPI](https://img.shields.io/pypi/v/lsprotocol?label=lsprotocol)](https://pypi.org/p/lsprotocol) | Active |
| Rust | generator.plugins.rust | [![Crates](https://img.shields.io/crates/v/lsprotocol)](https://crates.io/crates/lsprotocol) | Active |
| Dotnet | generator.plugins.dotnet | <in development> | Under development |
| Language | Plugin Module | Package | Status | Documentation |
| ---------------- | ------------------------ | --------------------------------------------------------------------------------------------------- | ----------------- | ----------------------------------------------------------- |
| Python | generator.plugins.python | [![PyPI](https://img.shields.io/pypi/v/lsprotocol?label=lsprotocol)](https://pypi.org/p/lsprotocol) | Active | [Python package README](./packages/python/README.md) |
| Rust | generator.plugins.rust | [![Crates](https://img.shields.io/crates/v/lsprotocol)](https://crates.io/crates/lsprotocol) | Active | [Rust package README](./packages/rust/lsprotocol/README.md) |
| Dotnet | generator.plugins.dotnet | <in development> | Under development |
| <in development> |
2 changes: 1 addition & 1 deletion packages/python/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Language Server Protocol Types implementation for Python

`lsprotocol` is a python implementation of object types used in the Language Server Protocol (LSP). This repository contains the code generator and the generated types for LSP.
`lsprotocol` is a Python implementation of object types used in the Language Server Protocol (LSP). This repository contains the code generator and the generated types for LSP.

## Overview

Expand Down
128 changes: 65 additions & 63 deletions packages/python/lsprotocol/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import enum
import functools
from typing import Any, Dict, Optional, Sequence, Tuple, Union

import attrs

from . import validators

__lsp_version__ = "3.17.0"
Expand Down Expand Up @@ -3533,9 +3535,9 @@ class HoverParams:
class Hover:
"""The result of a hover request."""

contents: Union[
"MarkupContent", MarkedString, Sequence[MarkedString]
] = attrs.field()
contents: Union["MarkupContent", MarkedString, Sequence[MarkedString]] = (
attrs.field()
)
"""The hover's content"""

range: Optional["Range"] = attrs.field(default=None)
Expand Down Expand Up @@ -5817,14 +5819,14 @@ class ServerCapabilities:
)
"""The server provides find references support."""

document_highlight_provider: Optional[
Union[bool, DocumentHighlightOptions]
] = attrs.field(default=None)
document_highlight_provider: Optional[Union[bool, DocumentHighlightOptions]] = (
attrs.field(default=None)
)
"""The server provides document highlight support."""

document_symbol_provider: Optional[
Union[bool, DocumentSymbolOptions]
] = attrs.field(default=None)
document_symbol_provider: Optional[Union[bool, DocumentSymbolOptions]] = (
attrs.field(default=None)
)
"""The server provides document symbol support."""

code_action_provider: Optional[Union[bool, CodeActionOptions]] = attrs.field(
Expand All @@ -5845,24 +5847,24 @@ class ServerCapabilities:
] = attrs.field(default=None)
"""The server provides color provider support."""

workspace_symbol_provider: Optional[
Union[bool, WorkspaceSymbolOptions]
] = attrs.field(default=None)
workspace_symbol_provider: Optional[Union[bool, WorkspaceSymbolOptions]] = (
attrs.field(default=None)
)
"""The server provides workspace symbol support."""

document_formatting_provider: Optional[
Union[bool, DocumentFormattingOptions]
] = attrs.field(default=None)
document_formatting_provider: Optional[Union[bool, DocumentFormattingOptions]] = (
attrs.field(default=None)
)
"""The server provides document formatting."""

document_range_formatting_provider: Optional[
Union[bool, DocumentRangeFormattingOptions]
] = attrs.field(default=None)
"""The server provides document range formatting."""

document_on_type_formatting_provider: Optional[
DocumentOnTypeFormattingOptions
] = attrs.field(default=None)
document_on_type_formatting_provider: Optional[DocumentOnTypeFormattingOptions] = (
attrs.field(default=None)
)
"""The server provides document formatting on typing."""

rename_provider: Optional[Union[bool, RenameOptions]] = attrs.field(default=None)
Expand Down Expand Up @@ -5949,9 +5951,9 @@ class ServerCapabilities:
@since 3.17.0"""
# Since: 3.17.0

inline_completion_provider: Optional[
Union[bool, InlineCompletionOptions]
] = attrs.field(default=None)
inline_completion_provider: Optional[Union[bool, InlineCompletionOptions]] = (
attrs.field(default=None)
)
"""Inline completion options used during static registration.

@since 3.18.0
Expand Down Expand Up @@ -6062,9 +6064,9 @@ class Diagnostic:
@since 3.15.0"""
# Since: 3.15.0

related_information: Optional[
Sequence["DiagnosticRelatedInformation"]
] = attrs.field(default=None)
related_information: Optional[Sequence["DiagnosticRelatedInformation"]] = (
attrs.field(default=None)
)
"""An array of related diagnostic information, e.g. when symbol-names within
a scope collide all definitions can be marked via this property."""

Expand Down Expand Up @@ -6658,9 +6660,9 @@ class NotebookDocumentCellChanges:
"""Changes to notebook cells properties like its
kind, execution summary or metadata."""

text_content: Optional[
Sequence["NotebookDocumentCellContentChanges"]
] = attrs.field(default=None)
text_content: Optional[Sequence["NotebookDocumentCellContentChanges"]] = (
attrs.field(default=None)
)
"""Changes to the text content of notebook cells."""


Expand Down Expand Up @@ -7065,14 +7067,14 @@ class WorkspaceClientCapabilities:
)
"""Capabilities specific to `WorkspaceEdit`s."""

did_change_configuration: Optional[
"DidChangeConfigurationClientCapabilities"
] = attrs.field(default=None)
did_change_configuration: Optional["DidChangeConfigurationClientCapabilities"] = (
attrs.field(default=None)
)
"""Capabilities specific to the `workspace/didChangeConfiguration` notification."""

did_change_watched_files: Optional[
"DidChangeWatchedFilesClientCapabilities"
] = attrs.field(default=None)
did_change_watched_files: Optional["DidChangeWatchedFilesClientCapabilities"] = (
attrs.field(default=None)
)
"""Capabilities specific to the `workspace/didChangeWatchedFiles` notification."""

symbol: Optional["WorkspaceSymbolClientCapabilities"] = attrs.field(default=None)
Expand Down Expand Up @@ -7101,9 +7103,9 @@ class WorkspaceClientCapabilities:
@since 3.6.0"""
# Since: 3.6.0

semantic_tokens: Optional[
"SemanticTokensWorkspaceClientCapabilities"
] = attrs.field(default=None)
semantic_tokens: Optional["SemanticTokensWorkspaceClientCapabilities"] = (
attrs.field(default=None)
)
"""Capabilities specific to the semantic token requests scoped to the
workspace.

Expand Down Expand Up @@ -7247,14 +7249,14 @@ class TextDocumentClientCapabilities:
)
"""Capabilities specific to the `textDocument/formatting` request."""

range_formatting: Optional[
"DocumentRangeFormattingClientCapabilities"
] = attrs.field(default=None)
range_formatting: Optional["DocumentRangeFormattingClientCapabilities"] = (
attrs.field(default=None)
)
"""Capabilities specific to the `textDocument/rangeFormatting` request."""

on_type_formatting: Optional[
"DocumentOnTypeFormattingClientCapabilities"
] = attrs.field(default=None)
on_type_formatting: Optional["DocumentOnTypeFormattingClientCapabilities"] = (
attrs.field(default=None)
)
"""Capabilities specific to the `textDocument/onTypeFormatting` request."""

rename: Optional["RenameClientCapabilities"] = attrs.field(default=None)
Expand Down Expand Up @@ -7297,9 +7299,9 @@ class TextDocumentClientCapabilities:
@since 3.16.0"""
# Since: 3.16.0

linked_editing_range: Optional[
"LinkedEditingRangeClientCapabilities"
] = attrs.field(default=None)
linked_editing_range: Optional["LinkedEditingRangeClientCapabilities"] = (
attrs.field(default=None)
)
"""Capabilities specific to the `textDocument/linkedEditingRange` request.

@since 3.16.0"""
Expand Down Expand Up @@ -7430,9 +7432,9 @@ class GeneralClientCapabilities:
@since 3.16.0"""
# Since: 3.16.0

position_encodings: Optional[
Sequence[Union[PositionEncodingKind, str]]
] = attrs.field(default=None)
position_encodings: Optional[Sequence[Union[PositionEncodingKind, str]]] = (
attrs.field(default=None)
)
"""The position encodings supported by the client. Client and server
have to agree on the same position encoding to ensure that offsets
(e.g. character position in a line) are interpreted the same on both
Expand Down Expand Up @@ -7729,9 +7731,9 @@ class WorkspaceEditClientCapabilities:
@since 3.16.0"""
# Since: 3.16.0

change_annotation_support: Optional[
"ChangeAnnotationsSupportOptions"
] = attrs.field(default=None)
change_annotation_support: Optional["ChangeAnnotationsSupportOptions"] = (
attrs.field(default=None)
)
"""Whether the client in general supports change annotations on text edits,
create file, rename file and delete file changes.

Expand Down Expand Up @@ -8261,9 +8263,9 @@ class CodeActionClientCapabilities:
)
"""Whether code action supports dynamic registration."""

code_action_literal_support: Optional[
"ClientCodeActionLiteralOptions"
] = attrs.field(default=None)
code_action_literal_support: Optional["ClientCodeActionLiteralOptions"] = (
attrs.field(default=None)
)
"""The client support code action literals of type `CodeAction` as a valid
response of the `textDocument/codeAction` request. If the property is not
set the request can only return `Command` literals.
Expand Down Expand Up @@ -8439,9 +8441,9 @@ class RenameClientCapabilities:
@since 3.12.0"""
# Since: 3.12.0

prepare_support_default_behavior: Optional[
PrepareSupportDefaultBehavior
] = attrs.field(default=None)
prepare_support_default_behavior: Optional[PrepareSupportDefaultBehavior] = (
attrs.field(default=None)
)
"""Client supports the default behavior result.

The value indicates the default behavior used by the
Expand Down Expand Up @@ -9016,9 +9018,9 @@ class ClientCompletionItemOptions:
@since 3.16.0"""
# Since: 3.16.0

insert_text_mode_support: Optional[
"ClientCompletionItemInsertTextModeOptions"
] = attrs.field(default=None)
insert_text_mode_support: Optional["ClientCompletionItemInsertTextModeOptions"] = (
attrs.field(default=None)
)
"""The client supports the `insertTextMode` property on
a completion item to override the whitespace handling mode
as defined by the client (see `insertTextMode`).
Expand Down Expand Up @@ -9089,9 +9091,9 @@ class ClientSignatureInformationOptions:
"""Client supports the following content formats for the documentation
property. The order describes the preferred format of the client."""

parameter_information: Optional[
"ClientSignatureParameterInformationOptions"
] = attrs.field(default=None)
parameter_information: Optional["ClientSignatureParameterInformationOptions"] = (
attrs.field(default=None)
)
"""Client capabilities specific to parameter information."""

active_parameter_support: Optional[bool] = attrs.field(
Expand Down
Loading