summaryrefslogtreecommitdiffstats
path: root/tests/lsp_tests/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lsp_tests/conftest.py')
-rw-r--r--tests/lsp_tests/conftest.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/lsp_tests/conftest.py b/tests/lsp_tests/conftest.py
new file mode 100644
index 0000000..8b42582
--- /dev/null
+++ b/tests/lsp_tests/conftest.py
@@ -0,0 +1,43 @@
+import pytest
+from debputy.plugin.api.feature_set import PluginProvidedFeatureSet
+
+try:
+ from pygls.server import LanguageServer
+ from lsprotocol.types import (
+ InitializeParams,
+ ClientCapabilities,
+ GeneralClientCapabilities,
+ PositionEncodingKind,
+ TextDocumentItem,
+ Position,
+ CompletionParams,
+ TextDocumentIdentifier,
+ HoverParams,
+ MarkupContent,
+ )
+ from debputy.lsp.lsp_features import lsp_set_plugin_features
+
+ HAS_PYGLS = True
+except ImportError:
+ HAS_PYGLS = False
+
+
+@pytest.fixture()
+def ls(debputy_plugin_feature_set: PluginProvidedFeatureSet) -> "LanguageServer":
+ if not HAS_PYGLS:
+ pytest.skip("Missing pygls")
+ ls = LanguageServer("debputy", "v<test>")
+ ls.lsp.lsp_initialize(
+ InitializeParams(
+ ClientCapabilities(
+ general=GeneralClientCapabilities(
+ position_encodings=[PositionEncodingKind.Utf32],
+ )
+ )
+ )
+ )
+ lsp_set_plugin_features(debputy_plugin_feature_set)
+ try:
+ yield ls
+ finally:
+ lsp_set_plugin_features(None)