Skip to content

Notebook Document support is not implemented correctly #1066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
moucha19 opened this issue Oct 13, 2023 · 5 comments · Fixed by #1077
Closed

Notebook Document support is not implemented correctly #1066

moucha19 opened this issue Oct 13, 2023 · 5 comments · Fixed by #1077

Comments

@moucha19
Copy link

Hello,

I was trying to connect from the LanguageClient to the pylsp server and when I did this with the current version of pylsp that supports LSP v. 3.17, the Initialize call ends in following Exception related to JSON Deserialization:

Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'OmniSharp.Extensions.LanguageServer.Protocol.Models.NotebookSelector' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly

I did some digging and the culprit seems to be this part of the pylsp response that specifies server capabilities:

'notebookDocumentSync': {'notebookSelector': [{'cells': [{'language': 'python'}]}]}

As you can see, the top-level object of notebookSelector is array, which is (if I understand the LSP documentation correctly) a valid syntax, but the LanguageClient does not seem to support it.

@manandre

This comment was marked as outdated.

@manandre
Copy link
Contributor

manandre commented Oct 20, 2023

Sorry I misread the LSP spec, the payload is right.
I have been influenced by the invalid example in the specification :/

{
  notebookDocumentSync: {
    notebookSelector: {
      notebook: { scheme: 'file', notebookType: 'jupyter-notebook' },
      cells: [{ language: 'python' }]
    }
  }
}

@manandre
Copy link
Contributor

The implementation is not aligned on the LSP 3.17 specification.

public partial class NotebookDocumentSyncOptions : INotebookDocumentRegistrationOptions
{
///
/// The notebook to be synced. If a string
/// value is provided it matches against the
/// notebook type. '*' matches every notebook.
///
public NotebookSelector NotebookSelector { get; set; }

NotebookSelector should be handled as an array/container.

@manandre
Copy link
Contributor

manandre commented Oct 20, 2023

For information, pylsp have recently changed their implementation to comply to the specification.
See python-lsp/python-lsp-server#453
https://github.com/python-lsp/python-lsp-server/releases/tag/v1.8.2

@manandre
Copy link
Contributor

LSP documentation fix: microsoft/language-server-protocol#1831
Implementation fix: #1077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants