How to change language mode of VSCode programmatically?

typescript, visual-studio-code, vscode-extensions

Solution

Currently this is not possible. Here is the corresponding issue on GitHub. You should upvote (thumbs up) it to tell them we want this.

Problem

I have tried `vscode.commands.executeCommand('workbench.action.editor.changeLanguageMode', 'JSON');`. But it does nothing more than open a panel. And `TextDocument.languageId` is an readonly property.

Original source