tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
diff --git a/packages/tailwindcss-language-service/src/util/state.ts b/packages/tailwindcss-language-service/src/util/state.ts
index 137cf82bcd0a7f226c391e8c6f0618660f24d6fb..7919befcb440c12ca809af17b0a24df556cce38e 100644
--- a/packages/tailwindcss-language-service/src/util/state.ts
+++ b/packages/tailwindcss-language-service/src/util/state.ts
@@ -60,6 +60,7 @@
export interface State {
enabled: boolean
configPath?: string
+ configModified?: number
config?: any
version?: string
separator?: string
diff --git a/src/server.ts b/src/server.ts
index d775d1a9ec4fd7bd67d6df1be79705f6ac30d90b..09b8d0db68dea0a8dc4f03bc8bd427594e8ca105 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -142,9 +142,37 @@ connection: Connection,
params: InitializeParams,
documentService: DocumentService
): Promise<ProjectService> {
+ const state: State = {
+ enabled: false,
+ editor: {
import './lib/env'
+ return URI.parse(documentUri).fsPath
+ globalSettings: params.initializationOptions.configuration as Settings,
import {
+ // TODO
+ capabilities: {
+ configuration: true,
+ diagnosticRelatedInformation: true,
+ },
+ documents: documentService.documents,
+ CompletionRequest,
Connection,
+ if (documentSettingsCache.has(uri)) {
+ return documentSettingsCache.get(uri)
+ }
+ let config = await connection.workspace.getConfiguration({
+ section: 'tailwindCSS',
+ scopeUri: uri,
+ })
+ documentSettingsCache.set(uri, config)
+ return config
+ },
+ getDocumentSymbols: (uri: string) => {
+ return connection.sendRequest('@/tailwindCSS/getDocumentSymbols', { uri })
+ },
+ },
+ }
+
const documentSettingsCache: Map<string, Settings> = new Map()
let registrations: Promise<BulkUnregistration>
@@ -257,33 +285,6 @@
async function init() {
clearRequireCache()
- // TODO
- state.editor = {
- connection,
- globalSettings: params.initializationOptions.configuration as Settings,
- userLanguages: {},
- // TODO
- capabilities: {
- configuration: true,
- diagnosticRelatedInformation: true,
- },
- documents: documentService.documents,
- getConfiguration: async (uri?: string) => {
- if (documentSettingsCache.has(uri)) {
- return documentSettingsCache.get(uri)
- }
- let config = await connection.workspace.getConfiguration({
- section: 'tailwindCSS',
- scopeUri: uri,
- })
- documentSettingsCache.set(uri, config)
- return config
- },
- getDocumentSymbols: (uri: string) => {
- return connection.sendRequest('@/tailwindCSS/getDocumentSymbols', { uri })
- },
- }
-
let [configPath] = (
await glob([`**/${CONFIG_FILE_GLOB}`], {
cwd: folder,
@@ -327,6 +328,7 @@ pnpApi.setup()
setPnpApi(pnpApi)
}
+ const configModified = fs.statSync(configPath).mtimeMs
const configDir = path.dirname(configPath)
let tailwindcss: any
let postcss: any
@@ -358,6 +360,16 @@ tailwindcss = __non_webpack_require__(tailwindcssPath)
tailwindcssVersion = tailwindcssPkg.version
console.log(`Loaded tailwindcss v${tailwindcssVersion}: ${tailwindDir}`)
+ if (
+ state.enabled &&
+ postcssVersion === state.modules.postcss.version &&
+ tailwindcssVersion === state.modules.tailwindcss.version &&
+ configPath === state.configPath &&
+ configModified === state.configModified
+ ) {
+ return
+ }
+
try {
resolveConfigFn = __non_webpack_require__(resolveFrom(tailwindDir, './resolveConfig.js'))
} catch (_) {
@@ -434,6 +446,7 @@ )
}
state.configPath = configPath
+ state.configModified = configModified
state.modules = {
tailwindcss: { version: tailwindcssVersion, module: tailwindcss },
postcss: { version: postcssVersion, module: postcss },