diff --git a/src/extension.ts b/src/extension.ts index 3d29a99..0afa66b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -13,6 +13,7 @@ import { createOutputChannel, onDidChangeConfiguration, registerCommand } from ' import { registerLanguageStatusItem, updateStatus } from './common/status'; let lsClient: LanguageClient | undefined; +let watcher: vscode.FileSystemWatcher | undefined; export async function activate(context: vscode.ExtensionContext): Promise { // This is required to get server name and module. This should be // the first thing that we do in this extension. @@ -44,6 +45,18 @@ export async function activate(context: vscode.ExtensionContext): Promise } }; + const workspaceFolder = vscode.workspace.workspaceFolders?.[0]; + + if (workspaceFolder) { + const fullPath = `${workspaceFolder.uri.fsPath}/pyproject.toml`; + watcher = vscode.workspace.createFileSystemWatcher(fullPath); + + watcher.onDidChange((uri) => { + console.log('pyproject.toml changed'); + vscode.commands.executeCommand('mypy-type-checker.restart', uri.fsPath); + }); + } + context.subscriptions.push( onDidChangePythonInterpreter(async () => { await runServer();