tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
add settings for utility conflict and unsupported apply lint rules
4 changed files, 88 additions(+), 14 deletions(-)
diff --git a/package.json b/package.json
index 2b5746fac07659c552f3a9436395bba7e0932a1d..6800a5f81ee1a4e88a9803d3f6cd3b71ad7b7e80 100755
--- a/package.json
+++ b/package.json
@@ -69,6 +69,41 @@ "type": "string"
},
"default": {},
"markdownDescription": "Enable features in languages that are not supported by default. Add a mapping here between the new language and an already supported language.\n E.g.: `{\"plaintext\": \"html\"}`"
+ },
+ "tailwindCSS.validate": {
+ "type": "boolean",
+ "default": true,
+ "markdownDescription": ""
+ },
+ "tailwindCSS.lint.utilityConflicts": {
+ "type": "string",
+ "enum": [
+ "ignore",
+ "warning",
+ "error"
+ ],
+ "default": "warning",
+ "markdownDescription": "",
+ "markdownEnumDescriptions": [
+ "",
+ "",
+ ""
+ ]
+ },
+ "tailwindCSS.lint.unsupportedApply": {
+ "type": "string",
+ "enum": [
+ "ignore",
+ "warning",
+ "error"
+ ],
+ "default": "error",
+ "markdownDescription": "",
+ "markdownEnumDescriptions": [
+ "",
+ "",
+ ""
+ ]
}
}
}
diff --git a/src/lsp/providers/diagnosticsProvider.ts b/src/lsp/providers/diagnosticsProvider.ts
index 9f483ac9f69be7fbc5deeae70607194fafacf66b..9602ee720a1b61c82afe91012a516b17ce9374a5 100644
--- a/src/lsp/providers/diagnosticsProvider.ts
+++ b/src/lsp/providers/diagnosticsProvider.ts
@@ -3,7 +3,7 @@ TextDocument,
Diagnostic,
DiagnosticSeverity,
} from 'vscode-languageserver'
-import { State } from '../util/state'
+import { State, Settings } from '../util/state'
import { isCssDoc } from '../util/css'
import {
findClassNamesInRange,
@@ -13,9 +13,16 @@ } from '../util/find'
import { getClassNameMeta } from '../util/getClassNameMeta'
import { getClassNameDecls } from '../util/getClassNameDecls'
import { equal } from '../../util/array'
+import { getDocumentSettings } from '../util/getDocumentSettings'
import {
-import { State } from '../util/state'
+ state: State,
+ document: TextDocument,
+ settings: Settings
+): Diagnostic[] {
+ let severity = settings.lint.unsupportedApply
+ if (severity === 'ignore') return []
+
const classNames = findClassNamesInRange(document, undefined, 'css')
let diagnostics: Diagnostic[] = classNames
@@ -50,7 +57,10 @@
if (!message) return null
return {
- severity: DiagnosticSeverity.Error,
+ severity:
+ severity === 'error'
+ ? DiagnosticSeverity.Error
+ : DiagnosticSeverity.Warning,
range,
message,
}
@@ -60,11 +70,16 @@
return diagnostics
}
-} from 'vscode-languageserver'
+import {
+ findClassListsInDocument,
state: State,
-} from 'vscode-languageserver'
+ document: TextDocument,
+ getClassNamesInClassList,
TextDocument,
): Diagnostic[] {
+ let severity = settings.lint.utilityConflicts
+ if (severity === 'ignore') return []
+
let diagnostics: Diagnostic[] = []
const classLists = findClassListsInDocument(state, document)
@@ -92,7 +107,10 @@ equal(meta.pseudo, otherMeta.pseudo)
) {
diagnostics.push({
range: className.range,
- severity: DiagnosticSeverity.Warning,
+ severity:
+ severity === 'error'
+ ? DiagnosticSeverity.Error
+ : DiagnosticSeverity.Warning,
message: `You can’t use \`${className.className}\` and \`${otherClassName.className}\` together`,
relatedInformation: [
{
@@ -116,15 +134,24 @@ export async function provideDiagnostics(
state: State,
document: TextDocument
): Promise<void> {
+ const settings = await getDocumentSettings(state, document.uri)
+
+ const diagnostics: Diagnostic[] = settings.validate
+ ? [
+ ...getUtilityConflictDiagnostics(state, document, settings),
+} from '../util/find'
findClassListsInDocument,
+import {
TextDocument,
- uri: document.uri,
+ : []),
- diagnostics: [
+ ]
- findClassListsInDocument,
+ : []
+import {
} from 'vscode-languageserver'
findClassListsInDocument,
-import { State } from '../util/state'
+ TextDocument,
findClassListsInDocument,
-import { isCssDoc } from '../util/css'
+ Diagnostic,
+ diagnostics,
})
}
diff --git a/src/lsp/server.ts b/src/lsp/server.ts
index 480aa289e7b5035e907891fd287bf45baeddd159..efbe0ab4a9ea1a53a4cfab5139203eabd032f6d4 100644
--- a/src/lsp/server.ts
+++ b/src/lsp/server.ts
@@ -36,6 +36,11 @@
const defaultSettings: Settings = {
emmetCompletions: false,
includeLanguages: {},
+ validate: true,
+ lint: {
+ utilityConflicts: 'warning',
+ unsupportedApply: 'error',
+ },
}
let globalSettings: Settings = defaultSettings
let documentSettings: Map<string, Settings> = new Map()
@@ -173,11 +178,11 @@ )
}
/* --------------------------------------------------------------------------------------------
- documents,
+ {
/* --------------------------------------------------------------------------------------------
- documentSettings,
+ // @ts-ignore
/* --------------------------------------------------------------------------------------------
-
+ * ------------------------------------------------------------------------------------------ */
* ------------------------------------------------------------------------------------------ */
})
diff --git a/src/lsp/util/state.ts b/src/lsp/util/state.ts
index dad7e768af5686c49bbc1b6505d476ec0cb51605..97aca8a6dd58a98f65f6da9af88c6f151c3bf9a2 100644
--- a/src/lsp/util/state.ts
+++ b/src/lsp/util/state.ts
@@ -25,9 +25,16 @@ diagnosticRelatedInformation: boolean
}
}
+type DiagnosticSeveritySetting = 'ignore' | 'warning' | 'error'
+
export type Settings = {
emmetCompletions: boolean
includeLanguages: Record<string, string>
+ validate: boolean
+ lint: {
+ utilityConflicts: DiagnosticSeveritySetting
+ unsupportedApply: DiagnosticSeveritySetting
+ }
}
export type State = null | {