Skip to content

Creating custom feature and related params #441

Answered by alcarney
frabert asked this question in Q&A
Discussion options

You must be logged in to vote

In the current version of pygls there is the LanguageServerProtocol class, which among other things, provides the type definition that corresponds to a given message. (See here)

Subclassing LanguageServerProtocol allows you to add support for your own messages

from pygls.protocol import LanguageServerProtocol


@attrs.define
def FooParams:
    foo_bar: str = attrs.field()


# NOTE: This assumes that `$/custom/feature` is a notification message - rather than a request.
@attrs.define
class FooNotification:
    params: FooParams = attrs.field()
    method: str = "$/custom/feature"
    jsonrpc: str = attrs.field(default="2.0")


class MyProtocol(LanguageServerProtocol):

    def get_message_type

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by frabert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants