From 802d6d24e4f53c6f3d1ddc0b5aaf59d666c6ea54 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Mon, 18 Aug 2025 15:05:37 +0200 Subject: [PATCH] Expose a pylsp_shutdown() hook This allows plugins to perform some operations (e.g. terminating a daemon process or cleaning temporary resources) upon LSP server shutdown. --- pylsp/hookspecs.py | 5 +++++ pylsp/python_lsp.py | 1 + 2 files changed, 6 insertions(+) diff --git a/pylsp/hookspecs.py b/pylsp/hookspecs.py index e7e7ce42..cf97c745 100644 --- a/pylsp/hookspecs.py +++ b/pylsp/hookspecs.py @@ -138,3 +138,8 @@ def pylsp_signature_help(config, workspace, document, position) -> None: @hookspec def pylsp_workspace_configuration_changed(config, workspace) -> None: pass + + +@hookspec +def pylsp_shutdown(config, workspace) -> None: + pass diff --git a/pylsp/python_lsp.py b/pylsp/python_lsp.py index 36265890..16027c7a 100644 --- a/pylsp/python_lsp.py +++ b/pylsp/python_lsp.py @@ -237,6 +237,7 @@ def __getitem__(self, item): def m_shutdown(self, **_kwargs) -> None: for workspace in self.workspaces.values(): workspace.close() + self._hook("pylsp_shutdown") self._shutdown = True def m_invalid_request_after_shutdown(self, **_kwargs):