Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added setting to configure languages the extension should provide suggestions #81

Merged
merged 2 commits into from
Jan 31, 2024
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
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
Loading