Skip to content

Commit

Permalink
feat: Volar TakeOver Mode watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
adhamfarrag committed Jan 23, 2024
1 parent c6e4a1b commit 7259f69
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { window, ExtensionContext, commands, Uri } from 'vscode';
import { window, ExtensionContext, commands, Uri, extensions } from 'vscode';
import nuxtrCommands from './commands'
import { ModulesView } from './sideBar'
import { logger, updateDependencies } from './utils';
import codelens from './codelens'
import { statusBars, activateStatusBarIcons } from './statusBar'
import { activateIntellisense } from './intellisense'
import { filesWatcher } from './watchers'
import { filesWatcher, checkTakeOverMode } from './watchers'

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

// checkTakeOverMode
checkTakeOverMode()

extensionCommands.forEach(({ command, function: commandFunction }) => {
context.subscriptions.push(commands.registerCommand(command, commandFunction));
});
Expand Down
4 changes: 3 additions & 1 deletion src/watchers/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import filesWatcher from './files'
import { snippetsConfigWatcher, templatesConfigWatcher, piniaConfigWatcher } from './config'

import { checkTakeOverMode} from './vscode'
export {
filesWatcher,
snippetsConfigWatcher,
templatesConfigWatcher,
piniaConfigWatcher
piniaConfigWatcher,
checkTakeOverMode
}
29 changes: 29 additions & 0 deletions src/watchers/vscode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { extensions, window , commands} from "vscode";
import { openExternalLink, isNuxtTwo } from "../utils";

const checkTakeOverMode = async () => {
const tsExtension = extensions.getExtension('vscode.typescript-language-features')
console.log('tsExtension', tsExtension);

if (tsExtension !== undefined && !isNuxtTwo()) {
const message = await window.showWarningMessage(
`Volar's TakeOver mode is not enabled`, 'Enable', 'Learn More'
)

if (message === 'Learn More') {
openExternalLink('https://nuxt.com/docs/getting-started/installation#prerequisites')
}

if (message === 'Enable') {
await commands.executeCommand('workbench.view.extensions');
await commands.executeCommand('workbench.extensions.action.showExtensionsWithIds', ['vscode.typescript-language-features']);
await commands.executeCommand(
'workbench.extensions.action.enableExtension',
'vscode.typescript-language-features'
)
}
}
}


export { checkTakeOverMode }

0 comments on commit 7259f69

Please sign in to comment.