aboutsummaryrefslogtreecommitdiffstats
path: root/qt-core/src/recommended-settings.ts
blob: 792756cf8d7d76266850c32c94277d8a3fb24cd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only

import * as vscode from 'vscode';
import * as path from 'path';

import { isMultiWorkspace, telemetry } from 'qt-lib';
import { EXTENSION_ID } from '@/constants';

interface RecommendedSetting {
  extensionId: string;
  setting: string;
  value: string;
}

export function registerSetRecommendedSettingsCommand() {
  const recommendedSettings: RecommendedSetting[] = [
    {
      extensionId: 'cmake',
      setting: 'options.statusBarVisibility',
      value: 'visible'
    },
    {
      extensionId: 'cmake',
      setting: 'buildDirectory',
      value: `\${workspaceFolder}${path.sep}builds${path.sep}\${buildKit}${path.sep}\${buildType}`
    }
  ];

  const configurationTarget = isMultiWorkspace()
    ? vscode.ConfigurationTarget.Workspace
    : undefined;
  const recommendedSettingsCommand = vscode.commands.registerCommand(
    `${EXTENSION_ID}.setRecommendedSettings`,
    () => {
      telemetry.sendAction('setRecommendedSettings');
      for (const { extensionId, setting, value } of recommendedSettings) {
        void vscode.workspace
          .getConfiguration(extensionId)
          .update(setting, value, configurationTarget);
      }
    }
  );
  return recommendedSettingsCommand;
}