Skip to content

Commit

Permalink
feat: add option to disable incremental update
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Sep 3, 2022
1 parent 2b6c3c7 commit 3b46963
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
15 changes: 15 additions & 0 deletions extensions/vscode-vue-language-features/package.json
Expand Up @@ -307,6 +307,21 @@
"default": "off",
"description": "Traces the communication between VS Code and the language server."
},
"volar.vueserver.textDocumentSync": {
"type": "string",
"default": "incremental",
"enum": [
"incremental",
"full",
"none"
],
"enumDescriptions": [
"Documents are synced by sending the full content on open. After that only incremental updates to the document are send.",
"Documents are synced by always sending the full content of the document.",
"Documents should not be synced at all."
],
"description": "Defines how the host (editor) should sync document changes to the language server. SFC incremental parser only working when config \"incremental\"."
},
"volar.vueserver.useSecondServer": {
"type": "boolean",
"default": false,
Expand Down
6 changes: 6 additions & 0 deletions extensions/vscode-vue-language-features/src/common.ts
Expand Up @@ -236,7 +236,13 @@ function getInitializationOptions(
mode: 'main-language-features' | 'second-language-features' | 'document-features',
useSecondServer: boolean,
) {
const textDocumentSync = vscode.workspace.getConfiguration('volar').get<'incremental' | 'full' | 'none'>('vueserver.textDocumentSync');
const initializationOptions: ServerInitializationOptions = {
textDocumentSync: textDocumentSync ? {
incremental: lsp.TextDocumentSyncKind.Incremental,
full: lsp.TextDocumentSyncKind.Full,
none: lsp.TextDocumentSyncKind.None,
}[textDocumentSync] : lsp.TextDocumentSyncKind.Incremental,
typescript: tsVersion.getCurrentTsPaths(context),
languageFeatures: (mode === 'main-language-features' || mode === 'second-language-features') ? {
...(mode === 'main-language-features' ? {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-language-server/src/common.ts
Expand Up @@ -38,7 +38,7 @@ export function createLanguageServer(

const result: vscode.InitializeResult = {
capabilities: {
textDocumentSync: vscode.TextDocumentSyncKind.Incremental,
textDocumentSync: (options.textDocumentSync as vscode.TextDocumentSyncKind) ?? vscode.TextDocumentSyncKind.Incremental,
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/vue-language-server/src/types.ts
Expand Up @@ -45,6 +45,7 @@ export interface LanguageConfigs {
}

export interface ServerInitializationOptions {
textDocumentSync?: vscode.TextDocumentSyncKind | number;
typescript: {
/**
* Path to tsserverlibrary.js / tsserver.js / typescript.js
Expand Down

0 comments on commit 3b46963

Please sign in to comment.