Skip to content
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

Refactor for Server Initialization Options #1916

Merged
merged 7 commits into from Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/svelte/package.json
Expand Up @@ -14,9 +14,6 @@
"engines": {
"vscode": "^1.67.0"
},
"keywords": [
"svelte"
],
"activationEvents": [
"onLanguage:svelte"
],
Expand Down
34 changes: 3 additions & 31 deletions examples/svelte/src/client.ts
@@ -1,4 +1,4 @@
import { ServerInitializationOptions } from '@volar/language-server';
import { InitializationOptions } from '@volar/language-server';
import * as path from 'path';
import * as vscode from 'vscode';
import * as lsp from 'vscode-languageclient/node';
Expand All @@ -8,37 +8,9 @@ let client: lsp.BaseLanguageClient;
export async function activate(context: vscode.ExtensionContext) {

const documentSelector: lsp.DocumentSelector = [{ language: 'svelte' }];
const initializationOptions: ServerInitializationOptions = {
const initializationOptions: InitializationOptions = {
typescript: {
serverPath: path.join(vscode.env.appRoot, 'extensions', 'node_modules', 'typescript', 'lib', 'typescript.js'),
},
languageFeatures: {
references: true,
implementation: true,
definition: true,
typeDefinition: true,
callHierarchy: true,
hover: true,
rename: true,
renameFileRefactoring: true,
signatureHelp: true,
codeAction: true,
workspaceSymbol: true,
completion: true,
documentHighlight: true,
documentLink: true,
codeLens: true,
semanticTokens: true,
inlayHints: true,
diagnostics: true,
},
documentFeatures: {
selectionRange: true,
foldingRange: true,
linkedEditingRange: true,
documentSymbol: true,
documentColor: true,
documentFormatting: true,
tsdk: path.join(vscode.env.appRoot, 'extensions', 'node_modules', 'typescript', 'lib'),
},
};
const serverModule = vscode.Uri.joinPath(context.extensionUri, 'out', 'server');
Expand Down
14 changes: 3 additions & 11 deletions extensions/vscode-vue-language-features/package.json
Expand Up @@ -18,14 +18,6 @@
"engines": {
"vscode": "^1.67.0"
},
"keywords": [
"volar",
"vue",
"vue3",
"ts",
"typescript",
"pug"
],
"activationEvents": [
"onLanguage:vue",
"onLanguage:markdown",
Expand Down Expand Up @@ -269,7 +261,7 @@
"type": "object",
"title": "Volar",
"properties": {
"volar-language-features.trace.server": {
"vue-semantic-server-1.trace.server": {
"scope": "window",
"type": "string",
"enum": [
Expand All @@ -280,7 +272,7 @@
"default": "off",
"description": "Traces the communication between VS Code and the language server."
},
"volar-language-features-2.trace.server": {
"vue-semantic-server-2.trace.server": {
"scope": "window",
"type": "string",
"enum": [
Expand All @@ -291,7 +283,7 @@
"default": "off",
"description": "Traces the communication between VS Code and the language server."
},
"volar-document-features.trace.server": {
"vue-syntactic-server.trace.server": {
"scope": "window",
"type": "string",
"enum": [
Expand Down
Expand Up @@ -9,8 +9,15 @@ export function activate(context: vscode.ExtensionContext) {
name,
documentSelector,
initOptions,
fillInitializeParams,
) => {

class _LanguageClient extends lsp.LanguageClient {
fillInitializeParams(params: lsp.InitializeParams) {
fillInitializeParams(params);
}
}

const serverMain = vscode.Uri.joinPath(context.extensionUri, 'dist/browser/server.js');
const worker = new Worker(serverMain.toString());
const clientOptions: lsp.LanguageClientOptions = {
Expand All @@ -22,7 +29,7 @@ export function activate(context: vscode.ExtensionContext) {
},
middleware,
};
const client = new lsp.LanguageClient(
const client = new _LanguageClient(
id,
name,
clientOptions,
Expand Down