Skip to content

Commit

Permalink
Merge pull request #81 from Cellule/languages-setting
Browse files Browse the repository at this point in the history
Added setting to configure languages the extension should provide suggestions
  • Loading branch information
vunguyentuan authored Jan 31, 2024
2 parents fe021ae + d887de0 commit 6bd4d2a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-students-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vscode-css-variables": patch
---

Added setting to configure languages the extension should provide suggestions
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

By default the extension only scan files with this glob patterns:
By default the extension only scan files with this glob patterns:

```json
[
Expand All @@ -26,7 +26,6 @@ And ignore files in these folders:
"**/.hg",
"**/CVS",
"**/.DS_Store",
"**/.git",
"**/node_modules",
"**/bower_components",
"**/tmp",
Expand All @@ -35,6 +34,28 @@ And ignore files in these folders:
]
```

And provides suggestions to files for the following languages

```json
[
"astro",
"svelte",
"vue",
"vue-html",
"vue-postcss",
"scss",
"postcss",
"less",
"css",
"html",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"source.css.styled"
]
```

## Features
### Autocomplete & Color Preview

Expand Down
8 changes: 3 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion packages/vscode-css-variables/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@
]
}
},
"cssVariables.languages": {
"type": "array",
"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).",
"default": [
"astro",
"svelte",
"vue",
"vue-html",
"vue-postcss",
"scss",
"postcss",
"less",
"css",
"html",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"source.css.styled"
],
"scope": 3
},
"cssVariables.blacklistFolders": {
"type": "array",
"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).",
Expand All @@ -70,7 +92,6 @@
"**/.hg",
"**/CVS",
"**/.DS_Store",
"**/.git",
"**/node_modules",
"**/bower_components",
"**/tmp",
Expand Down
37 changes: 20 additions & 17 deletions packages/vscode-css-variables/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,28 @@ export function activate(context: ExtensionContext) {
},
};

const settings = workspace.getConfiguration('cssVariables');
const languages = settings.get('languages', [
'astro',
'svelte',
'vue',
'vue-html',
'vue-postcss',
'scss',
'postcss',
'less',
'css',
'html',
'javascript',
'javascriptreact',
'typescript',
'typescriptreact',
'source.css.styled',
]);

// Options to control the language client
const clientOptions: LanguageClientOptions = {
documentSelector: [
'onLanguage:astro',
'onLanguage:svelte',
'onLanguage:vue',
'onLanguage:vue-html',
'onLanguage:vue-postcss',
'onLanguage:scss',
'onLanguage:postcss',
'onLanguage:less',
'onLanguage:css',
'onLanguage:html',
'onLanguage:javascript',
'onLanguage:javascriptreact',
'onLanguage:typescript',
'onLanguage:typescriptreact',
'onLanguage:source.css.styled',
].map((event) => ({
documentSelector: languages.map((event) => ({
scheme: 'file',
language: event.split(':')[1],
})),
Expand Down

0 comments on commit 6bd4d2a

Please sign in to comment.