Skip to content

Commit 7259f69

Browse files
committed
feat: Volar TakeOver Mode watcher
1 parent c6e4a1b commit 7259f69

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

Diff for: src/extension.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { window, ExtensionContext, commands, Uri } from 'vscode';
1+
import { window, ExtensionContext, commands, Uri, extensions } from 'vscode';
22
import nuxtrCommands from './commands'
33
import { ModulesView } from './sideBar'
44
import { logger, updateDependencies } from './utils';
55
import codelens from './codelens'
66
import { statusBars, activateStatusBarIcons } from './statusBar'
77
import { activateIntellisense } from './intellisense'
8-
import { filesWatcher } from './watchers'
8+
import { filesWatcher, checkTakeOverMode } from './watchers'
99

1010
const extensionCommands = [
1111
{ command: 'nuxtr.createPage', function: nuxtrCommands.createPage },
@@ -96,6 +96,9 @@ export async function activateExtension(context: ExtensionContext) {
9696
// activate codelens
9797
codelens.activateCodelenses(context)
9898

99+
// checkTakeOverMode
100+
checkTakeOverMode()
101+
99102
extensionCommands.forEach(({ command, function: commandFunction }) => {
100103
context.subscriptions.push(commands.registerCommand(command, commandFunction));
101104
});

Diff for: src/watchers/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import filesWatcher from './files'
22
import { snippetsConfigWatcher, templatesConfigWatcher, piniaConfigWatcher } from './config'
33

4+
import { checkTakeOverMode} from './vscode'
45
export {
56
filesWatcher,
67
snippetsConfigWatcher,
78
templatesConfigWatcher,
8-
piniaConfigWatcher
9+
piniaConfigWatcher,
10+
checkTakeOverMode
911
}

Diff for: src/watchers/vscode.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { extensions, window , commands} from "vscode";
2+
import { openExternalLink, isNuxtTwo } from "../utils";
3+
4+
const checkTakeOverMode = async () => {
5+
const tsExtension = extensions.getExtension('vscode.typescript-language-features')
6+
console.log('tsExtension', tsExtension);
7+
8+
if (tsExtension !== undefined && !isNuxtTwo()) {
9+
const message = await window.showWarningMessage(
10+
`Volar's TakeOver mode is not enabled`, 'Enable', 'Learn More'
11+
)
12+
13+
if (message === 'Learn More') {
14+
openExternalLink('https://nuxt.com/docs/getting-started/installation#prerequisites')
15+
}
16+
17+
if (message === 'Enable') {
18+
await commands.executeCommand('workbench.view.extensions');
19+
await commands.executeCommand('workbench.extensions.action.showExtensionsWithIds', ['vscode.typescript-language-features']);
20+
await commands.executeCommand(
21+
'workbench.extensions.action.enableExtension',
22+
'vscode.typescript-language-features'
23+
)
24+
}
25+
}
26+
}
27+
28+
29+
export { checkTakeOverMode }

0 commit comments

Comments
 (0)