Skip to content

Commit

Permalink
lsp: Allow features to register shutdown handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Feb 10, 2024
1 parent fa5bc15 commit 46a91bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/esbonio/esbonio/server/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def initialize(self, params: types.InitializeParams):
def initialized(self, params: types.InitializedParams):
"""Called when the ``initialized`` notification is received."""

def shutdown(self, params: None):
"""Called when the server is instructed to ``shutdown`` by the client."""

def document_change(self, params: types.DidChangeTextDocumentParams):
"""Called when a text document is changed."""

Expand Down
3 changes: 3 additions & 0 deletions lib/esbonio/esbonio/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ async def initialized(self, params: types.InitializedParams):
)
self._ready.set_result(True)

def lsp_shutdown(self, params: None):
"""Called when the server is instructed to ``shutdown`` by the client."""

def load_extension(self, name: str, setup: Callable):
"""Load the given setup function as an extension.
Expand Down
5 changes: 5 additions & 0 deletions lib/esbonio/esbonio/server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ async def on_initialized(
await ls.initialized(params)
await call_features(ls, "initialized", params)

@server.feature(types.SHUTDOWN)
async def on_shutdown(ls: EsbonioLanguageServer, params: None):
ls.lsp_shutdown(params)
await call_features(ls, "shutdown", params)

@server.feature(types.TEXT_DOCUMENT_DID_CHANGE)
async def on_document_change(
ls: EsbonioLanguageServer, params: types.DidChangeTextDocumentParams
Expand Down

0 comments on commit 46a91bc

Please sign in to comment.