Skip to content

Commit

Permalink
Refactor for Server Initialization Options (#1916)
Browse files Browse the repository at this point in the history
* refactor: remove languageFeatures, documentFeatures from ServerInitializationOptions

* feat: re-add ignoreTriggerCharacters

* refactor: simplify client code

* refactor: config ts paths as single option

* chore: fix `*.trace.server` properties

* refactor: ServerInitializationOptions -> InitializationOptions

* refactor: enum values
  • Loading branch information
johnsoncodehk committed Sep 30, 2022
1 parent c5aff0d commit a75fdf2
Show file tree
Hide file tree
Showing 28 changed files with 447 additions and 687 deletions.
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

0 comments on commit a75fdf2

Please sign in to comment.