Skip to content

Announce supported capabilities #391

@predragnikolic

Description

@predragnikolic

LSP clients(like Sublime Text), won't send server requests if the server didn't announce support for those requests through capabilities.

Currently the Volar server only announces this capability:
https://github.com/johnsoncodehk/volar/blob/8733e9483389d9567525f0493b56697fe8f2c35a/packages/server/src/index.ts#L34-L36

But it should actually include lots of other capabilities.
Here is an example of what the Vetur server returns:

Details

Note: I accidentally lowercased all the object keys :)

{
	"capabilities": {
		"foldingrangeprovider": true,
		"codeactionprovider": {
			"codeactionkinds": ["quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeimports"],
			"resolveprovider": true
		},
		"signaturehelpprovider": {
			"triggercharacters": ["("] 
		},
		"colorprovider": true,
		"semantictokensprovider": {
			"legend": {
				"tokenmodifiers": ["declaration", "static", "async", "readonly", "defaultlibrary", "local", "refvalue"],
				"tokentypes": ["class", "enum", "interface", "namespace", "typeparameter", "type", "parameter", "variable", "enummember", "property", "function", "method"]
			},
			"range": true,
			"full": true
		},
		"workspace": {
			"fileoperations": {
				"willrename": {
					"filters": [
						{
							"pattern": {
								"glob": "**/*.{ts,js,vue}"
							}
						}
					]
				}
			},
			"workspacefolders": {
				"changenotifications": true,
				"supported": true
			}
		},
		"completionprovider": {
			"triggercharacters": [".", ":", "<", "\"", "'", "/", "@", "*", " "],
			"resolveprovider": true
		},
		"hoverprovider": true,
		"executecommandprovider": {
			"commands": []
		},
		"documentlinkprovider": {
			"resolveprovider": false
		},
		"referencesprovider": true,
		"definitionprovider": true,
		"documenthighlightprovider": true,
		"textdocumentsync": {
			"didclose": {},
			"save": {},
			"didopen": {},
			"change": {
				"synckind": 2
			}
		},
		"documentformattingprovider": false,
		"documentsymbolprovider": true
	}
}

Additional context:

Even when I add a completion capability for completions:

	const result: vscode.InitializeResult = {
		capabilities: {
			textDocumentSync: vscode.TextDocumentSyncKind.Incremental,
			completionProvider: {
				triggerCharacters: ['.']
			}
		}
	};

When a LSP client sends a request to Volar,
Volar returns this error:

Client sends a request to volar:
:: --> LSP-volar textDocument/completion(5): {'position': {'line': 0, 'character': 0}, 'textDocument': {'uri': 'file:///home/predragnikolic/.config/sublime-text/Packages/LSP-volar/index.vue'}}

Volar sends back this:
:: <~~ LSP-volar 5: {'message': 'Unhandled method textDocument/completion', 'code': -32601}

So even when Volar has specified capabilities, the server still will not work with other LSP clients (just yet :). Do you have any idea why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions