1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts
index f05c842feb17c67448b4e07269c7d47e020f7343..6b6877cb8baaeddb2e05bb3c0c94263a4d2be74a 100644
--- a/packages/tailwindcss-language-server/src/server.ts
+++ b/packages/tailwindcss-language-server/src/server.ts
@@ -211,12 +211,33 @@ params: InitializeParams,
documentService: DocumentService
): Promise<ProjectService> {
const disposables: Disposable[] = []
+ const documentSettingsCache: Map<string, Settings> = new Map()
+
+ async function getConfiguration(uri?: string) {
+ if (documentSettingsCache.has(uri)) {
+ return documentSettingsCache.get(uri)
+ }
+ let [editor, tailwindCSS] = await Promise.all([
+ connection.workspace.getConfiguration({
+ section: 'editor',
+ scopeUri: uri,
+ }),
+ connection.workspace.getConfiguration({
+ section: 'tailwindCSS',
+ scopeUri: uri,
+ }),
+ ])
+ let config: Settings = { editor, tailwindCSS }
+ documentSettingsCache.set(uri, config)
+ return config
+ }
+
const state: State = {
enabled: false,
editor: {
connection,
folder,
- globalSettings: params.initializationOptions.configuration as Settings,
+ globalSettings: await getConfiguration(),
userLanguages: params.initializationOptions.userLanguages
? params.initializationOptions.userLanguages
: {},
@@ -226,35 +247,17 @@ configuration: true,
diagnosticRelatedInformation: true,
},
documents: documentService.documents,
- getConfiguration: async (uri?: string) => {
- if (documentSettingsCache.has(uri)) {
- return documentSettingsCache.get(uri)
- }
- let [editor, tailwindCSS] = await Promise.all([
- connection.workspace.getConfiguration({
- section: 'editor',
- scopeUri: uri,
- }),
- connection.workspace.getConfiguration({
- section: 'tailwindCSS',
- scopeUri: uri,
- }),
- ])
- let config: Settings = { editor, tailwindCSS }
- documentSettingsCache.set(uri, config)
- return config
- },
+ getConfiguration,
getDocumentSymbols: (uri: string) => {
return connection.sendRequest('@/tailwindCSS/getDocumentSymbols', { uri })
},
},
}
- const documentSettingsCache: Map<string, Settings> = new Map()
let registrations: Promise<BulkUnregistration>
let chokidarWatcher: chokidar.FSWatcher
- let ignore = state.editor.globalSettings.tailwindCSS.files.exclude
+ let ignore = state.editor.globalSettings.tailwindCSS.files?.exclude ?? []
function onFileEvents(changes: Array<{ file: string; type: FileChangeType }>): void {
let needsInit = false
@@ -447,7 +450,7 @@
let [configPath] = (
await glob([`**/${CONFIG_FILE_GLOB}`], {
cwd: folder,
- ignore: state.editor.globalSettings.tailwindCSS.files.exclude,
+ ignore: state.editor.globalSettings.tailwindCSS.files?.exclude ?? [],
onlyFiles: true,
absolute: true,
suppressErrors: true,
@@ -980,9 +983,9 @@ }
},
onUpdateSettings(settings: any): void {
documentSettingsCache.clear()
- let previousExclude = state.editor.globalSettings.tailwindCSS.files.exclude
+ let previousExclude = state.editor.globalSettings.tailwindCSS.files?.exclude ?? []
state.editor.globalSettings = settings
- if (!equal(previousExclude, settings.tailwindCSS.files.exclude)) {
+ if (!equal(previousExclude, settings.tailwindCSS.files?.exclude ?? [])) {
tryInit()
} else {
if (state.enabled) {
|