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.
2 Answers
Currently this is not possible. Here is the corresponding issue on GitHub. You should upvote (thumbs up) it to tell them we want this.
1 Comment
wheredidthatnamecomefrom
Looks like that feature is implemented now.