Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ A Visual Studio Code extension that provides CSS class name completion for the H
* HTML
* Razor
* PHP
* Laravel (Blade)
* JavaScript
* JavaScript React (.jsx)
* TypeScript React (.tsx)
Expand Down
37 changes: 9 additions & 28 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,34 +122,15 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}
}));

const htmlRegex = /class=["|']([\w- ]*$)/;
const jsxRegex = /className=["|']([\w- ]*$)/;

const html = provideCompletionItemsGenerator('html', htmlRegex);
const razor = provideCompletionItemsGenerator('razor', htmlRegex);
const php = provideCompletionItemsGenerator('php', htmlRegex);
const vue = provideCompletionItemsGenerator('vue', htmlRegex);
const twig = provideCompletionItemsGenerator('twig', htmlRegex);
const md = provideCompletionItemsGenerator('markdown', htmlRegex);
const tsReact = provideCompletionItemsGenerator('typescriptreact', jsxRegex);
const js = provideCompletionItemsGenerator('javascript', jsxRegex)
const jsReact = provideCompletionItemsGenerator('javascriptreact', jsxRegex);
const erb = provideCompletionItemsGenerator('erb', htmlRegex);
const hbs = provideCompletionItemsGenerator('handlebars', htmlRegex);
const ejs = provideCompletionItemsGenerator('ejs', htmlRegex);

context.subscriptions.push(html);
context.subscriptions.push(razor);
context.subscriptions.push(php);
context.subscriptions.push(vue);
context.subscriptions.push(twig);
context.subscriptions.push(md);
context.subscriptions.push(tsReact);
context.subscriptions.push(js);
context.subscriptions.push(jsReact);
context.subscriptions.push(erb);
context.subscriptions.push(hbs);
context.subscriptions.push(ejs);
// Javascript based extensions
['typescriptreact', 'javascript', 'javascriptreact'].forEach((extension) => {
context.subscriptions.push(provideCompletionItemsGenerator(extension, /className=["|']([\w- ]*$)/));
});

// HTML based extensions
['html', 'razor', 'php', 'blade', 'vue', 'twig', 'markdown', 'erb', 'handlebars', 'ejs'].forEach((extension) => {
context.subscriptions.push(provideCompletionItemsGenerator(extension, /class=["|']([\w- ]*$)/));
});

caching = true;
try {
Expand Down