From d402cd922d19a30d2af2ef6f007cd32d22720f0f Mon Sep 17 00:00:00 2001 From: Sharak Date: Fri, 11 Mar 2022 17:49:16 +0100 Subject: [PATCH] allow scanninng only specific location instead of whole workspace --- README.md | 7 +++++++ package.json | 5 +++++ src/unsafe/server.ts | 3 ++- src/unsafe/test/helpers.ts | 1 + src/unsafe/types/settings.ts | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fdb6c86..a7621e58 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,13 @@ Just install the plugin and use it. ## Supported settings +#### scss.scannerRoot + +* Type: `string` +* Default: `""` + +Set root directory for the scanner, relative to your workspace. `""` means whole workspace will be scanned. If your workspace has many .scss files unrelated to your current work, you should point the scanner to more specific location eg. `"themes/my-theme/src/scss"`. + #### scss.scannerDepth * Type: `number` diff --git a/package.json b/package.json index f0f8ff7b..55a7e73c 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,11 @@ "contributes": { "configuration": { "properties": { + "scss.scannerRoot": { + "type": "string", + "default": "", + "description": "Set root directory for the scanner, relative to your workspace. `\"\"` means whole workspace will be scanned. If your workspace has many .scss files unrelated to your current work, you should point the scanner to more specific location eg. `\"themes/my-theme/src/scss\"`." + }, "scss.scannerDepth": { "type": "number", "default": 30, diff --git a/src/unsafe/server.ts b/src/unsafe/server.ts index 104dae89..e36f2a11 100644 --- a/src/unsafe/server.ts +++ b/src/unsafe/server.ts @@ -25,6 +25,7 @@ import { searchWorkspaceSymbol } from './providers/workspaceSymbol'; import { findFiles } from './utils/fs'; import { getSCSSRegionsDocument } from './utils/vue'; import { URI } from 'vscode-uri'; +import * as path from 'path'; interface InitializationOption { workspace: string; @@ -56,8 +57,8 @@ connection.onInitialize( async (params: InitializeParams): Promise => { const options = params.initializationOptions as InitializationOption; - workspaceRoot = options.workspace; settings = options.settings; + workspaceRoot = path.join(options.workspace, settings.scannerRoot); storageService = new StorageService(); scannerService = new ScannerService(storageService, settings); diff --git a/src/unsafe/test/helpers.ts b/src/unsafe/test/helpers.ts index 0567e1e9..1898be2f 100644 --- a/src/unsafe/test/helpers.ts +++ b/src/unsafe/test/helpers.ts @@ -40,6 +40,7 @@ export function makeSameLineRange(line: number = 1, start: number = 1, end: numb export function makeSettings(options?: Partial): ISettings { return { + scannerRoot: '', scannerDepth: 30, scannerExclude: ['**/.git', '**/node_modules', '**/bower_components'], scanImportedFiles: true, diff --git a/src/unsafe/types/settings.ts b/src/unsafe/types/settings.ts index 97960569..d3a6e6a7 100644 --- a/src/unsafe/types/settings.ts +++ b/src/unsafe/types/settings.ts @@ -2,6 +2,7 @@ export interface ISettings { // Scanner + scannerRoot: string; scannerDepth: number; scannerExclude: string[]; scanImportedFiles: boolean;