Skip to content

Commit 3798d52

Browse files
committed
Added setting to configure languages the extension should provide suggestions
1 parent fe021ae commit 3798d52

File tree

4 files changed

+68
-25
lines changed

4 files changed

+68
-25
lines changed

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
**[Install via the Visual Studio Code Marketplace →](https://marketplace.visualstudio.com/items?itemName=vunguyentuan.vscode-css-variables)**
88

9-
By default the extension only scan files with this glob patterns:
9+
By default the extension only scan files with this glob patterns:
1010

1111
```json
1212
[
@@ -26,7 +26,6 @@ And ignore files in these folders:
2626
"**/.hg",
2727
"**/CVS",
2828
"**/.DS_Store",
29-
"**/.git",
3029
"**/node_modules",
3130
"**/bower_components",
3231
"**/tmp",
@@ -35,6 +34,28 @@ And ignore files in these folders:
3534
]
3635
```
3736

37+
And provides suggestions to files for the following languages
38+
39+
```json
40+
[
41+
"astro",
42+
"svelte",
43+
"vue",
44+
"vue-html",
45+
"vue-postcss",
46+
"scss",
47+
"postcss",
48+
"less",
49+
"css",
50+
"html",
51+
"javascript",
52+
"javascriptreact",
53+
"typescript",
54+
"typescriptreact",
55+
"source.css.styled"
56+
]
57+
```
58+
3859
## Features
3960
### Autocomplete & Color Preview
4061

package-lock.json

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vscode-css-variables/package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,28 @@
6161
]
6262
}
6363
},
64+
"cssVariables.languages": {
65+
"type": "array",
66+
"markdownDescription": "Configure the languages for which the extension should be activated. Read more about language identifiers [here](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers).",
67+
"default": [
68+
"astro",
69+
"svelte",
70+
"vue",
71+
"vue-html",
72+
"vue-postcss",
73+
"scss",
74+
"postcss",
75+
"less",
76+
"css",
77+
"html",
78+
"javascript",
79+
"javascriptreact",
80+
"typescript",
81+
"typescriptreact",
82+
"source.css.styled"
83+
],
84+
"scope": 3
85+
},
6486
"cssVariables.blacklistFolders": {
6587
"type": "array",
6688
"markdownDescription": "Configure glob patterns for excluding files and folders. The extension will not scan variables in these files and folders. Read more about glob patterns [here](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options).",
@@ -70,7 +92,6 @@
7092
"**/.hg",
7193
"**/CVS",
7294
"**/.DS_Store",
73-
"**/.git",
7495
"**/node_modules",
7596
"**/bower_components",
7697
"**/tmp",

packages/vscode-css-variables/src/index.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,28 @@ export function activate(context: ExtensionContext) {
3434
},
3535
};
3636

37+
const settings = workspace.getConfiguration('cssVariables');
38+
const languages = settings.get('languages', [
39+
'astro',
40+
'svelte',
41+
'vue',
42+
'vue-html',
43+
'vue-postcss',
44+
'scss',
45+
'postcss',
46+
'less',
47+
'css',
48+
'html',
49+
'javascript',
50+
'javascriptreact',
51+
'typescript',
52+
'typescriptreact',
53+
'source.css.styled',
54+
]);
55+
3756
// Options to control the language client
3857
const clientOptions: LanguageClientOptions = {
39-
documentSelector: [
40-
'onLanguage:astro',
41-
'onLanguage:svelte',
42-
'onLanguage:vue',
43-
'onLanguage:vue-html',
44-
'onLanguage:vue-postcss',
45-
'onLanguage:scss',
46-
'onLanguage:postcss',
47-
'onLanguage:less',
48-
'onLanguage:css',
49-
'onLanguage:html',
50-
'onLanguage:javascript',
51-
'onLanguage:javascriptreact',
52-
'onLanguage:typescript',
53-
'onLanguage:typescriptreact',
54-
'onLanguage:source.css.styled',
55-
].map((event) => ({
58+
documentSelector: languages.map((event) => ({
5659
scheme: 'file',
5760
language: event.split(':')[1],
5861
})),

0 commit comments

Comments
 (0)