From 08927cb7583784e402c8a872881dfc70d195e261 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Mon, 17 Jan 2022 15:14:09 +0000 Subject: [PATCH] Add default excluded files (for non-vscode clients) --- packages/tailwindcss-language-server/src/server.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts index 6b6877c..1ce4dd9 100644 --- a/packages/tailwindcss-language-server/src/server.ts +++ b/packages/tailwindcss-language-server/src/server.ts @@ -109,6 +109,7 @@ const TRIGGER_CHARACTERS = [ // JIT opacity modifiers '/', ] as const +const DEFAULT_FILES_EXCLUDE = ['**/.git/**', '**/.svn/**', '**/.hg/**', '**/node_modules/**'] const colorNames = Object.keys(namedColors) @@ -257,7 +258,7 @@ async function createProjectService( let registrations: Promise let chokidarWatcher: chokidar.FSWatcher - let ignore = state.editor.globalSettings.tailwindCSS.files?.exclude ?? [] + let ignore = state.editor.globalSettings.tailwindCSS.files?.exclude ?? DEFAULT_FILES_EXCLUDE function onFileEvents(changes: Array<{ file: string; type: FileChangeType }>): void { let needsInit = false @@ -450,7 +451,7 @@ async function createProjectService( let [configPath] = ( await glob([`**/${CONFIG_FILE_GLOB}`], { cwd: folder, - ignore: state.editor.globalSettings.tailwindCSS.files?.exclude ?? [], + ignore: state.editor.globalSettings.tailwindCSS.files?.exclude ?? DEFAULT_FILES_EXCLUDE, onlyFiles: true, absolute: true, suppressErrors: true, @@ -983,9 +984,10 @@ async function createProjectService( }, onUpdateSettings(settings: any): void { documentSettingsCache.clear() - let previousExclude = state.editor.globalSettings.tailwindCSS.files?.exclude ?? [] + let previousExclude = + state.editor.globalSettings.tailwindCSS.files?.exclude ?? DEFAULT_FILES_EXCLUDE state.editor.globalSettings = settings - if (!equal(previousExclude, settings.tailwindCSS.files?.exclude ?? [])) { + if (!equal(previousExclude, settings.tailwindCSS.files?.exclude ?? DEFAULT_FILES_EXCLUDE)) { tryInit() } else { if (state.enabled) {