From df304249fc1cba5f6bbbf6ef31e0cf85b79a2e72 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Sun, 8 Oct 2023 22:31:06 -0700 Subject: [PATCH] Expose version of the package and use it for the LspServer --- salt_lsp/__init__.py | 8 ++++++++ salt_lsp/server.py | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/salt_lsp/__init__.py b/salt_lsp/__init__.py index e69de29..ba40011 100644 --- a/salt_lsp/__init__.py +++ b/salt_lsp/__init__.py @@ -0,0 +1,8 @@ +from importlib import metadata + +try: + __version__ = metadata.version(__package__) +except: + __version__ = "dev" + +del metadata # avoid polluting the main namespace diff --git a/salt_lsp/server.py b/salt_lsp/server.py index bf11770..4dee35d 100644 --- a/salt_lsp/server.py +++ b/salt_lsp/server.py @@ -22,6 +22,7 @@ ) from pygls.server import LanguageServer +from salt_lsp import __version__ from salt_lsp import utils from salt_lsp.base_types import StateNameCompletion, SLS_LANGUAGE_ID from salt_lsp.workspace import SaltLspProto, SlsFileWorkspace @@ -39,7 +40,9 @@ class SaltServer(LanguageServer): LINE_START_REGEX = re.compile(r"^(\s*)\b", re.MULTILINE) def __init__(self) -> None: - super().__init__(protocol_cls=SaltLspProto) + super().__init__( + name="SaltStack", version=__version__, protocol_cls=SaltLspProto + ) self._state_name_completions: Dict[str, StateNameCompletion] = {}