Skip to content

Commit 64cf83e

Browse files
committed
set notebook server capabilities
1 parent 3e0b496 commit 64cf83e

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

jedi_language_server/server.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
MarkupContent,
6464
MarkupKind,
6565
MessageType,
66+
NotebookDocumentSyncOptions,
67+
NotebookDocumentSyncOptionsNotebookSelectorType2,
68+
NotebookDocumentSyncOptionsNotebookSelectorType2CellsType,
6669
ParameterInformation,
6770
RenameParams,
6871
SignatureHelp,
@@ -207,6 +210,18 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
207210
name="jedi-language-server",
208211
version=__version__,
209212
protocol_cls=JediLanguageServerProtocol,
213+
# Advertise support for Python notebook cells.
214+
notebook_document_sync=NotebookDocumentSyncOptions(
215+
notebook_selector=[
216+
NotebookDocumentSyncOptionsNotebookSelectorType2(
217+
cells=[
218+
NotebookDocumentSyncOptionsNotebookSelectorType2CellsType(
219+
language="python"
220+
)
221+
]
222+
)
223+
]
224+
),
210225
)
211226

212227

tests/lsp_tests/test_init_options.py renamed to tests/lsp_tests/test_initialize.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"""Tests for initialization options over language server protocol."""
1+
"""Tests for initialize requests."""
22

33
import copy
44
from threading import Event
55

6-
from hamcrest import assert_that
6+
from hamcrest import assert_that, is_
77

88
from tests.lsp_test_client import defaults, session
99

@@ -51,3 +51,30 @@ def _window_log_message_handler(params):
5151
"$.diagnostics']"
5252
)
5353
)
54+
55+
56+
def test_notebook_server_capabilities() -> None:
57+
"""Test that the server's notebook capabilities are set correctly."""
58+
actual = []
59+
60+
def _process_server_capabilities(capabilities):
61+
actual.append(capabilities)
62+
63+
initialize_params = copy.deepcopy(defaults.VSCODE_DEFAULT_INITIALIZE)
64+
initialize_params["capabilities"]["notebookDocument"] = {
65+
"synchronization": {
66+
"dynamicRegistration": True,
67+
"executionSummarySupport": True,
68+
},
69+
}
70+
with session.LspSession() as ls_session:
71+
ls_session.initialize(initialize_params, _process_server_capabilities)
72+
73+
assert_that(len(actual) == 1)
74+
for params in actual:
75+
assert_that(
76+
params["capabilities"]["notebookDocumentSync"],
77+
is_(
78+
{"notebookSelector": [{"cells": [{"language": "python"}]}]}
79+
),
80+
)

0 commit comments

Comments
 (0)