I’ve been playing around with the LanguageClient
interface to implement Ruff’s native language server support into my extension but faced the following error:
Ruff connection closed unexpectedly: typeMismatch(NovaFoundation.LSP.ServerCapabilities.NotebookDocumentSync.NotebookSelector.DocumentFilter, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "result", intValue: nil), CodingKeys(stringValue: "capabilities", intValue: nil), CodingKeys(stringValue: "notebookDocumentSync", intValue: nil), CodingKeys(stringValue: "notebookSelector", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "Expected NotebookDocumentFilter or String.", underlyingError: nil))
In other words, it expects items of the result.capabilities.notebookDocumentSync.notebookSelector
array to have the first field with a string
or NotebookDocumentFilter
value all the time. So, it always expects the notebook
field.
The original RPC response was this (truncated a bit):
{
"jsonrpc" : "2.0",
"result" : {
"serverInfo" : {
"version" : "0.6.1",
"name" : "ruff"
},
"capabilities" : {
"notebookDocumentSync" : {
"save" : false,
"notebookSelector" : [
{
"cells" : [
{
"language" : "python"
}
]
}
]
},
…
},
…
},
"id" : 0
}
I suspect Nova’s expectations do not correlate with the LSP spec, where objects of the notebookSelector
array easily may have only the cells
field.
Please correct me if I’m wrong here. It doesn’t look like other editors with LSP have this problem, and it’s an issue on Ruff’s end.