client/registerCapability sent for workspace/didChangeWorkspaceFolder even if dynamicRegistration set to false during initialization
See original GitHub issueMoving from https://github.com/microsoft/pyright/issues/1302
Describe the bug
We have support for pyright as one of the language servers for neovim’s built in language client which uses vscode-languageserver-node. One issue seems to be cropping up on node 15 where failed callbacks result in node terminating the process. The main callback that is failing is client/registerCapability, (our client doesn’t support dynamic registration). When we report dynamicRegistration as false, pyright is still sending client/registerCapability requests
[ DEBUG ] 2020-12-20T13:55:08-0800 ] /home/michael/neovim/share/nvim/runtime/lua/vim/lsp/rpc.lua:489 ]
"decoded" { id = 0, jsonrpc = "2.0", method = "client/registerCapability", params = { registrations = { {
id = "807eedda-04cf-4637-9cb7-81d5f5d0e225", method = "workspace/didChangeWorkspaceFolders",
registerOptions = vim.empty_dict() } } }}
We’re initializing the server with all dynamicRegistration capabilities registered as false
json of initialization params
{
"initialize_params": {
"capabilities": {
"callHierarchy": {
"dynamicRegistration": false,
"textDocument": {
"codeAction": {
"codeActionLiteralSupport": {
"codeActionKind": {
"valueSet": [
"",
"Empty",
"QuickFix",
"Refactor",
"RefactorExtract",
"RefactorInline",
"RefactorRewrite",
"Source",
"SourceOrganizeImports",
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
}
},
"dynamicRegistration": false
},
"completion": {
"completionItem": {
"commitCharactersSupport": false,
"deprecatedSupport": false,
"documentationFormat": [
"markdown",
"plaintext"
],
"preselectSupport": false,
"snippetSupport": false
},
"completionItemKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
],
"contextSupport": false,
"dynamicRegistration": false
},
"declaration": {
"linkSupport": true
},
"definition": {
"linkSupport": true
},
"documentHighlight": {
"dynamicRegistration": false
},
"documentSymbol": {
"dynamicRegistration": false,
"hierarchicalDocumentSymbolSupport": true,
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
}
},
"hover": {
"contentFormat": [
"markdown",
"plaintext"
],
"dynamicRegistration": false
},
" implementation": {
" linkSupport": true
},
"references": {
"dynamicRegistration": false
},
"rename": {
"dynamicRegistration": false,
"prepareSupport": true
},
"signatureHelp": {
"dynamicRegistration": false,
"signatureInformation": {
"documentationFormat": [
"markdown",
"plaintext"
]
}
},
" synchronization": {
"didSave": true,
"dynamicRegistration": false,
"willSave": false,
"willSaveWaitUntil": false
},
" typeDefinition": {
" linkSupport": true
}
},
"workspace": {
"applyEdit": true,
"configuration": true,
"symbol": {
"dynamicRegistration": false,
"hierarchicalWorkspaceSymbolSupport": true,
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
}
},
"workspaceFolders": true
}
},
"initializationOptions": {},
"processId": 53558,
"rootPath": "/home/michael/Repositories/pytorch_learning",
"rootUri": "file:///home/michael/Repositories/pytorch_learning",
"trace": "off",
"workspaceFolders": [
{
"name": "/home/michael/Repositories/pytorch_learning",
"uri": "file:///home/michael/Repositories/pytorch_learning"
}
]
}
}
}
}
To Reproduce This can’t be reproduced in vscode. I believe lsp-mode for emacs also implements dynamic registration, so the only way to reproduce this is to install neovim and nvim-lspconfig on node 14 (which doesn’t crash). I know this is out of scope for pyright so I will do all of the legwork on fixing this.
Expected behavior Pyright doesn’t send registerCapability requests to the client if dynamicRegistration is set to false (or unset)
VS Code extension or command-line Are you running pyright as a VS Code extension or a command-line tool? Which version? You can find the version of the VS Code extension by clicking on the Pyright icon in the extensions panel.
Additional context As mentioned I’m happy to submit a PR to fix this if acceptable, I’ve just had trouble finding exactly where in the pyright languageserver extension dynamicRegistration is read from initialization params, and where the registerCapability request is triggered.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top GitHub Comments
Actually there is already a property on the server side to control this. It is
changeNotifications
defined here: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_workspaceFoldersI changed the code to honor that flag when accessing
onDidChangeWorkspaceFolders
. I will also clarify the spec around this.Thank you! And also thank you for your work in supporting the broader language server protocol ecosystem!