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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Missing CSS support for HTML documents.
- Class attribute completion.
- Id attribute completion.
- Supports Zen Coding completion for class and id attributes.
- Scans workspace folder for css files.
- Scans workspace folder for css and scss files.
- Supports remote css files.
- Uses [vscode-css-languageservice](https://github.com/Microsoft/vscode-css-languageservice).

Expand All @@ -23,6 +23,7 @@ Missing CSS support for HTML documents.
- php
- twig
- md
- javascriptreact

## Remote Style Sheets

Expand All @@ -37,3 +38,6 @@ Remote style sheets can be specified in VS Code settings:
## Installation

[Visual Studio Code Marketplace](https://marketplace.visualstudio.com/items?itemName=ecmel.vscode-html-css)

## Usage
You can view a list of attributes via `ctrl + space`.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-html-css",
"displayName": "HTML CSS Support",
"description": "CSS support for HTML documents",
"version": "0.1.5",
"version": "0.1.6",
"publisher": "ecmel",
"license": "MIT",
"homepage": "https://github.com/ecmel/vscode-html-css",
Expand Down Expand Up @@ -48,7 +48,8 @@
"onLanguage:handlebars",
"onLanguage:php",
"onLanguage:twig",
"onLanguage:md"
"onLanguage:md",
"onLanguage:javascriptreact"
],
"main": "./out/src/extension",
"scripts": {
Expand Down
45 changes: 25 additions & 20 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Snippet {
class ClassServer implements vsc.CompletionItemProvider {

private regex = [
/(class|id)=["|']([^"^']*$)/i,
/(class|id|className)=["|']([^"^']*$)/i,
/(\.|\#)[^\.^\#^\<^\>]*$/i,
/<style[\s\S]*>([\s\S]*)<\/style>/ig
];
Expand Down Expand Up @@ -145,29 +145,32 @@ export function activate(context: vsc.ExtensionContext) {

if (vsc.workspace.rootPath) {

let glob = '**/*.css';
let globs = ['**/*.css', '**/*.scss'];

vsc.workspace.findFiles(glob, '').then(function (uris: vsc.Uri[]) {
for (let i = 0; i < uris.length; i++) {
parse(uris[i]);
}
globs.forEach(glob => {
vsc.workspace.findFiles(glob, '').then(function (uris: vsc.Uri[]) {
for (let i = 0; i < uris.length; i++) {
parse(uris[i]);
}
});

let watcher = vsc.workspace.createFileSystemWatcher(glob);

watcher.onDidCreate(function (uri: vsc.Uri) {
parse(uri);
});
watcher.onDidChange(function (uri: vsc.Uri) {
parse(uri);
});
watcher.onDidDelete(function (uri: vsc.Uri) {
delete map[uri.fsPath];
});

context.subscriptions.push(watcher);
});

parseRemoteConfig();

let watcher = vsc.workspace.createFileSystemWatcher(glob);

watcher.onDidCreate(function (uri: vsc.Uri) {
parse(uri);
});
watcher.onDidChange(function (uri: vsc.Uri) {
parse(uri);
});
watcher.onDidDelete(function (uri: vsc.Uri) {
delete map[uri.fsPath];
});

context.subscriptions.push(watcher);
};

let classServer = new ClassServer();
Expand All @@ -183,7 +186,8 @@ export function activate(context: vsc.ExtensionContext) {
'handlebars',
'php',
'twig',
'md'
'md',
'javascriptreact'
], classServer));

let wp = /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\.\"\,\<\>\/\?\s]+)/g;
Expand All @@ -198,6 +202,7 @@ export function activate(context: vsc.ExtensionContext) {
context.subscriptions.push(vsc.languages.setLanguageConfiguration('php', { wordPattern: wp }));
context.subscriptions.push(vsc.languages.setLanguageConfiguration('twig', { wordPattern: wp }));
context.subscriptions.push(vsc.languages.setLanguageConfiguration('md', { wordPattern: wp }));
context.subscriptions.push(vsc.languages.setLanguageConfiguration('javascriptreact', { wordPattern: wp }));

context.subscriptions.push(vsc.workspace.onDidChangeConfiguration((e) => parseRemoteConfig()));
}
Expand Down