Skip to content

Commit 3e0c457

Browse files
authored
Merge pull request #32 from rush1818/master
add support for javascriptreact
2 parents c34b31f + 4967749 commit 3e0c457

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Missing CSS support for HTML documents.
77
- Class attribute completion.
88
- Id attribute completion.
99
- Supports Zen Coding completion for class and id attributes.
10-
- Scans workspace folder for css files.
10+
- Scans workspace folder for css and scss files.
1111
- Supports remote css files.
1212
- Uses [vscode-css-languageservice](https://github.com/Microsoft/vscode-css-languageservice).
1313

@@ -23,6 +23,7 @@ Missing CSS support for HTML documents.
2323
- php
2424
- twig
2525
- md
26+
- javascriptreact
2627

2728
## Remote Style Sheets
2829

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

3940
[Visual Studio Code Marketplace](https://marketplace.visualstudio.com/items?itemName=ecmel.vscode-html-css)
41+
42+
## Usage
43+
You can view a list of attributes via `ctrl + space`.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-html-css",
33
"displayName": "HTML CSS Support",
44
"description": "CSS support for HTML documents",
5-
"version": "0.1.5",
5+
"version": "0.1.6",
66
"publisher": "ecmel",
77
"license": "MIT",
88
"homepage": "https://github.com/ecmel/vscode-html-css",
@@ -48,7 +48,8 @@
4848
"onLanguage:handlebars",
4949
"onLanguage:php",
5050
"onLanguage:twig",
51-
"onLanguage:md"
51+
"onLanguage:md",
52+
"onLanguage:javascriptreact"
5253
],
5354
"main": "./out/src/extension",
5455
"scripts": {

src/extension.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Snippet {
4343
class ClassServer implements vsc.CompletionItemProvider {
4444

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

146146
if (vsc.workspace.rootPath) {
147147

148-
let glob = '**/*.css';
148+
let globs = ['**/*.css', '**/*.scss'];
149149

150-
vsc.workspace.findFiles(glob, '').then(function (uris: vsc.Uri[]) {
151-
for (let i = 0; i < uris.length; i++) {
152-
parse(uris[i]);
153-
}
150+
globs.forEach(glob => {
151+
vsc.workspace.findFiles(glob, '').then(function (uris: vsc.Uri[]) {
152+
for (let i = 0; i < uris.length; i++) {
153+
parse(uris[i]);
154+
}
155+
});
156+
157+
let watcher = vsc.workspace.createFileSystemWatcher(glob);
158+
159+
watcher.onDidCreate(function (uri: vsc.Uri) {
160+
parse(uri);
161+
});
162+
watcher.onDidChange(function (uri: vsc.Uri) {
163+
parse(uri);
164+
});
165+
watcher.onDidDelete(function (uri: vsc.Uri) {
166+
delete map[uri.fsPath];
167+
});
168+
169+
context.subscriptions.push(watcher);
154170
});
155171

156172
parseRemoteConfig();
157173

158-
let watcher = vsc.workspace.createFileSystemWatcher(glob);
159-
160-
watcher.onDidCreate(function (uri: vsc.Uri) {
161-
parse(uri);
162-
});
163-
watcher.onDidChange(function (uri: vsc.Uri) {
164-
parse(uri);
165-
});
166-
watcher.onDidDelete(function (uri: vsc.Uri) {
167-
delete map[uri.fsPath];
168-
});
169-
170-
context.subscriptions.push(watcher);
171174
};
172175

173176
let classServer = new ClassServer();
@@ -183,7 +186,8 @@ export function activate(context: vsc.ExtensionContext) {
183186
'handlebars',
184187
'php',
185188
'twig',
186-
'md'
189+
'md',
190+
'javascriptreact'
187191
], classServer));
188192

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

202207
context.subscriptions.push(vsc.workspace.onDidChangeConfiguration((e) => parseRemoteConfig()));
203208
}

0 commit comments

Comments
 (0)