sublimelsp / LSP-volar

Vue support for Sublime's LSP plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crashes due to missing workspace settings

rchl opened this issue · comments

Just for fun I've tried to run the v1.0.5 release on Vue 2 project and got:

:: <-- LSP-volar workspace/configuration(6): {'items': [{'scopeUri': 'file:///Users/test.vue.html', 'section': 'html.hover'}]}
:: >>> LSP-volar 6: [None]
LSP-volar: /Users/rafal/Library/Caches/Sublime Text/Package Storage/LSP-volar/16.2.0/server/node_modules/vscode-html-languageservice/lib/umd/languageFacts/dataProvider.js:104
LSP-volar:         if (item.description && settings.documentation !== false) {
LSP-volar:                                          ^
LSP-volar: 
LSP-volar: TypeError: Cannot read property 'documentation' of null
LSP-volar:     at generateDocumentation (/Users/rafal/Library/Caches/Sublime Text/Package Storage/LSP-volar/16.2.0/server/node_modules/vscode-html-languageservice/lib/umd/languageFacts/dataProvider.js:104:42)
LSP-volar:     at /Users/rafal/Library/Caches/Sublime Text/Package Storage/LSP-volar/16.2.0/server/node_modules/vscode-html-languageservice/lib/umd/services/htmlHover.js:45:90
LSP-volar:     at Array.forEach (<anonymous>)
LSP-volar:     at _loop_1 (/Users/rafal/Library/Caches/Sublime Text/Package Storage/LSP-volar/16.2.0/server/node_modules/vscode-html-languageservice/lib/umd/services/htmlHover.js:43:44)
LSP-volar:     at getTagHover (/Users/rafal/Library/Caches/Sublime Text/Package Storage/LSP-volar/16.2.0/server/node_modules/vscode-html-languageservice/lib/umd/services/htmlHover.js:62:35)
LSP-volar:     at HTMLHover.doHover (/Users/rafal/Library/Caches/Sublime Text/Package Storage/LSP-volar/16.2.0/server/node_modules/vscode-html-languageservice/lib/umd/services/htmlHover.js:213:24)
LSP-volar:     at onHtml (/Users/rafal/Library/Caches/Sublime Text/Package Storage/LSP-volar/16.2.0/server/node_modules/vscode-vue-languageservice/out/services/hover.js:88:30)
LSP-volar:     at async Object.<anonymous> (/Users/rafal/Library/Caches/Sublime Text/Package Storage/LSP-volar/16.2.0/server/node_modules/vscode-vue-languageservice/out/services/hover.js:13:28)

Looks like we should define the settings section with relevant settings.

This problem should be resolved by vuejs/language-tools#678.

Thanks.

I think it also makes sense for us to clean up stuff here. We are currently passing all options through intializationOptions and probably we should do that through workspace options imstead.

Since you are the volar developer, maybe you can explain what is expected? Do we need to define those in both places or in setttings would be enough? Or somewhere in between?

The problem is that vscode-html-languageservice expected options is undefined or object (https://github.com/microsoft/vscode-html-languageservice/blob/94e5422c7fe92d9a507533b4fc3a08277cf39733/src/languageFacts/dataProvider.ts#L101), but got null from LSP.

For language server null or undefined is good, I think language server is responsible to handling (convert null and undefined to {}).

Yes, but what I'm asking is what's the preferred way for the volar server to receive the settings?

Through the initialize request's initializationOptions or through the workspace/didChangeConfiguration / workspace/configuration.

Or maybe it depends on the settings?

Volar gives priority to using workspace/didChangeConfiguration / workspace/configuration, and for special needs, initializationOptions will be used.
Because if use initializationOptions, we need another LSP request to implement the equivalent workspace/didChangeConfiguration.

For example, for tab name casing / attr name casing, volar supports documents to be set separately in its own status bar. The language server needs to query the language client for the name casing of each document, so it needs to use initializationOptions + language client request.

For html.hover settings, since it is the VSCode HTML extension's agreed settings, volar is always handled as workspace/didChangeConfiguration / workspace/configuration.

The reported issue has been fixed, so I will close it.