"""Shared pytest setup for the language server.""" import sys from pathlib import Path import pytest THIS_DIR = Path(__file__).parent SRC_DIR = THIS_DIR.parent.parent / "src" if str(SRC_DIR) not in sys.path: sys.path.insert(0, str(SRC_DIR)) import lsprotocol.types as lsp # type: ignore # noqa: E402 from lsp_server import LSP_SERVER # type: ignore # noqa: E402 from pygls.workspace import Workspace # noqa: E402 @pytest.fixture(scope="session", autouse=True) def initialize_test_workspace() -> None: """Provide the workspace that pygls 2 creates during LSP initialization.""" LSP_SERVER.protocol._workspace = Workspace( # pylint: disable=protected-access root_uri=None, sync_kind=lsp.TextDocumentSyncKind.Incremental, workspace_folders=[], position_encoding=lsp.PositionEncodingKind.Utf16, )