From 3798d52edbf6fb3701eaf85d8c29b3e6d26113b7 Mon Sep 17 00:00:00 2001 From: Michael Ferris Date: Tue, 30 Jan 2024 19:32:37 -0500 Subject: [PATCH 1/2] Added setting to configure languages the extension should provide suggestions --- README.md | 25 +++++++++++++-- package-lock.json | 8 ++--- packages/vscode-css-variables/package.json | 23 +++++++++++++- packages/vscode-css-variables/src/index.ts | 37 ++++++++++++---------- 4 files changed, 68 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 5a6339c..3781f99 100644 --- a/README.md +++ b/README.md @@ -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 [ @@ -26,7 +26,6 @@ And ignore files in these folders: "**/.hg", "**/CVS", "**/.DS_Store", - "**/.git", "**/node_modules", "**/bower_components", "**/tmp", @@ -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 diff --git a/package-lock.json b/package-lock.json index e92a1dc..8b13b09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10298,7 +10298,7 @@ } }, "packages/css-variables-language-server": { - "version": "2.6.1", + "version": "2.6.4", "license": "MIT", "dependencies": { "axios": "^0.27.2", @@ -10352,10 +10352,7 @@ } }, "packages/vscode-css-variables": { - "version": "2.6.1", - "dependencies": { - "css-variables-language-server": "*" - }, + "version": "2.6.3", "devDependencies": { "@types/mocha": "^9.1.1", "@types/node": "^18.7.13", @@ -10363,6 +10360,7 @@ "@typescript-eslint/eslint-plugin": "^5.35.1", "@typescript-eslint/parser": "^5.35.1", "@vscode/test-electron": "^2.1.5", + "css-variables-language-server": "*", "eslint": "^8.23.0", "eslint-config-airbnb-typescript": "^17.0.0", "mocha": "^10.0.0", diff --git a/packages/vscode-css-variables/package.json b/packages/vscode-css-variables/package.json index 84ad2be..55cf67a 100644 --- a/packages/vscode-css-variables/package.json +++ b/packages/vscode-css-variables/package.json @@ -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).", @@ -70,7 +92,6 @@ "**/.hg", "**/CVS", "**/.DS_Store", - "**/.git", "**/node_modules", "**/bower_components", "**/tmp", diff --git a/packages/vscode-css-variables/src/index.ts b/packages/vscode-css-variables/src/index.ts index f5bddb6..52c64ee 100644 --- a/packages/vscode-css-variables/src/index.ts +++ b/packages/vscode-css-variables/src/index.ts @@ -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], })), From d887de03c1ab54bf18b5239250f1bb6abc67db91 Mon Sep 17 00:00:00 2001 From: Michael Ferris Date: Tue, 30 Jan 2024 19:37:18 -0500 Subject: [PATCH 2/2] Add changeset --- .changeset/rude-students-mate.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/rude-students-mate.md diff --git a/.changeset/rude-students-mate.md b/.changeset/rude-students-mate.md new file mode 100644 index 0000000..9fe1ba7 --- /dev/null +++ b/.changeset/rude-students-mate.md @@ -0,0 +1,5 @@ +--- +"vscode-css-variables": patch +--- + +Added setting to configure languages the extension should provide suggestions