-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
29 lines (22 loc) · 1.19 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const vscode = require('vscode');
async function setSyntax(languageId) {
const activeEditor = vscode.window.activeTextEditor;
if (activeEditor) {
await vscode.languages.setTextDocumentLanguage(activeEditor.document, languageId);
}
}
function activate(context) {
const supportedLanguages = ['abap', 'bat', 'bibtex', 'clojure', 'coffeescript', 'c', 'cpp', 'csharp', 'css', 'diff', 'dockerfile', 'fsharp', 'git-commit', 'git-rebase', 'go', 'groovy', 'handlebars', 'haml', 'html', 'ini', 'java', 'javascript', 'javascriptreact', 'jsx', 'json', 'jsonc', 'latex', 'less', 'lua', 'makefile', 'markdown', 'objective-c', 'objective-cpp', 'perl', 'perl6', 'php', 'plaintext', 'powershell', 'jade', 'pug', 'python', 'r', 'razor', 'ruby', 'rust', 'scss', 'sass', 'shaderlab', 'shellscript', 'slim', 'sql', 'stylus', 'swift', 'typescript', 'typescriptreact', 'tex', 'vb', 'vue', 'vue-html', 'xml', 'xsl', 'yaml'];
const commands = {};
supportedLanguages.forEach(command => {
commands[command] = vscode.commands.registerCommand(
`set-syntax.${command}`, () => setSyntax(command)
)
});
context.subscriptions.push(...Object.values(commands));
}
function deactivate() {}
module.exports = {
activate,
deactivate
}