Skip to content

Commit

Permalink
feat: add setting for diagnostic model
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Oct 22, 2022
1 parent 1b0ac71 commit aa3e362
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
13 changes: 13 additions & 0 deletions extensions/vscode-vue-language-features/package.json
Expand Up @@ -306,6 +306,19 @@
],
"description": "Defines how the host (editor) should sync document changes to the language server. SFC incremental parser only working when config \"incremental\"."
},
"volar.vueserver.diagnosticModel": {
"type": "string",
"default": "push",
"enum": [
"push",
"pull"
],
"enumDescriptions": [
"Diagnostic push by language server.",
"Diagnostic pull by language client."
],
"description": "Diagnostic update model."
},
"volar.vueserver.maxOldSpaceSize": {
"type": [
"number",
Expand Down
23 changes: 12 additions & 11 deletions extensions/vscode-vue-language-features/src/common.ts
Expand Up @@ -66,9 +66,6 @@ async function doActivate(context: vscode.ExtensionContext, createLc: CreateLang

vscode.commands.executeCommand('setContext', 'volar.activated', true);

const _serverMaxOldSpaceSize = serverMaxOldSpaceSize();
const _additionalExtensions = additionalExtensions();

[semanticClient, syntacticClient] = await Promise.all([
createLc(
'vue-semantic-server',
Expand Down Expand Up @@ -124,10 +121,14 @@ async function doActivate(context: vscode.ExtensionContext, createLc: CreateLang
vscode.commands.executeCommand('workbench.action.reloadWindow');
}
function registerServerMaxOldSpaceSizeChange() {
vscode.workspace.onDidChangeConfiguration(async () => {
vscode.workspace.onDidChangeConfiguration(async (e) => {
if (
_serverMaxOldSpaceSize !== serverMaxOldSpaceSize()
|| _additionalExtensions.join(',') !== additionalExtensions().join(',')
e.affectsConfiguration('volar.vueserver.maxOldSpaceSize')
|| e.affectsConfiguration('volar.vueserver.diagnosticModel')
|| e.affectsConfiguration('volar.vueserver.noProjectReferences')
|| e.affectsConfiguration('volar.vueserver.petiteVue.processHtmlFile')
|| e.affectsConfiguration('volar.vueserver.vitePress.processMdFile')
|| e.affectsConfiguration('volar.vueserver.additionalExtensions')
) {
return requestReloadVscode();
}
Expand Down Expand Up @@ -191,10 +192,6 @@ export function getDocumentSelector(serverMode: ServerMode) {
return langs;
}

function serverMaxOldSpaceSize() {
return vscode.workspace.getConfiguration('volar').get<number | null>('vueserver.maxOldSpaceSize');
}

export function processHtml() {
return !!vscode.workspace.getConfiguration('volar').get<boolean>('vueserver.petiteVue.processHtmlFile');
}
Expand All @@ -207,6 +204,10 @@ export function noProjectReferences() {
return !!vscode.workspace.getConfiguration('volar').get<boolean>('vueserver.noProjectReferences');
}

export function diagnosticModel() {
return vscode.workspace.getConfiguration('volar').get<'push' | 'pull'>('vueserver.diagnosticModel');
}

function additionalExtensions() {
return vscode.workspace.getConfiguration('volar').get<string[]>('vueserver.additionalExtensions') ?? [];
}
Expand Down Expand Up @@ -264,7 +265,7 @@ function getInitializationOptions(
const textDocumentSync = vscode.workspace.getConfiguration('volar').get<'incremental' | 'full' | 'none'>('vueserver.textDocumentSync');
const initializationOptions: VueServerInitializationOptions = {
serverMode,
diagnosticModel: DiagnosticModel.Push,
diagnosticModel: diagnosticModel() === 'pull' ? DiagnosticModel.Pull : DiagnosticModel.Push,
textDocumentSync: textDocumentSync ? {
incremental: lsp.TextDocumentSyncKind.Incremental,
full: lsp.TextDocumentSyncKind.Full,
Expand Down

0 comments on commit aa3e362

Please sign in to comment.