Skip to content

Commit 42bc010

Browse files
committed
Added enabledLanguages and triggerCharacters config
1 parent dc6fa8e commit 42bc010

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ If it is not possible to specify remote styles with `<link rel="stylesheet">` ta
2121

2222
## Supported Languages
2323

24-
Support for other types of html like documents can be added in VS Code settings:
24+
Supported languages can be configured with the `css.enabledLanguages` configuration setting. By
25+
default "html" is enabled:
2526

2627
```json
27-
"files.associations": {
28-
"*.tpl": "html",
29-
"*.master": "html"
30-
}
28+
"css.enabledLanguages": [
29+
"html"
30+
]
3131
```
3232

3333
## Installation

package.json

Lines changed: 19 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": "1.0.1",
5+
"version": "1.0.2",
66
"publisher": "ecmel",
77
"license": "MIT",
88
"homepage": "https://github.com/ecmel/vscode-html-css",
@@ -26,7 +26,7 @@
2626
"multi-root ready"
2727
],
2828
"activationEvents": [
29-
"onLanguage:html"
29+
"onStartupFinished"
3030
],
3131
"contributes": {
3232
"configuration": {
@@ -37,6 +37,23 @@
3737
"default": [],
3838
"description": "A list of remote style sheets.",
3939
"scope": "resource"
40+
},
41+
"css.enabledLanguages": {
42+
"type": "array",
43+
"description": "A list of languages where suggestions are desired.",
44+
"default": [
45+
"html"
46+
],
47+
"scope": "window"
48+
},
49+
"css.triggerCharacters": {
50+
"type": "array",
51+
"description": "A list of trigger characters to start completion.",
52+
"default": [
53+
"\"",
54+
"'"
55+
],
56+
"scope": "window"
4057
}
4158
}
4259
}

src/extension.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,13 @@ export class ClassCompletionItemProvider implements CompletionItemProvider {
168168
}
169169

170170
export function activate(context: ExtensionContext) {
171+
const config = workspace.getConfiguration("css");
172+
const enabledLanguages = config.get<string[]>("enabledLanguages", ["html"]);
173+
const triggerCharacters = config.get<string[]>("triggerCharacters", ["\"", "'"]);
174+
171175
context.subscriptions.push(languages
172-
.registerCompletionItemProvider("html",
173-
new ClassCompletionItemProvider(), "\"", "'"));
176+
.registerCompletionItemProvider(enabledLanguages,
177+
new ClassCompletionItemProvider(), ...triggerCharacters));
174178
}
175179

176180
export function deactivate() { }

0 commit comments

Comments
 (0)