Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
Fix CSS conflict diagnostics in semicolonless CSS documents (#771)
Signature
-----BEGIN PGP SIGNATURE----- wsBcBAABCAAQBQJkSq4ZCRBK7hj4Ov3rIwAA9O0IAKsVzQnAv/lJtue0sjc5KFqO FMDTMaHsiSEwD5pQeRVpkow/P11PEZqu3ODNZ37+glOyKK0xy1SohjhwbsG+GM3B Yc5AFcwKtJFU9+WVP1FRuOtwbJ8z004mj7neP68GhuBtlRJTNlzePIAN+APJvseL 7esPHEhRjoOD6yVJ7OdWigiTsCwFOVxtNX3ZrlJyXZ/sdZ8qpmnQm6zws+D9JptC Oo3K7NANQpWGnIslpClHQSz+ON62nFrX78YiBHmAad3MsyI12rv4HeXospRLmy/z zp6yPkdDGq3N+EXCSq7dEueKLqEz2bqZFYON5h3DHuHzF+p1puaEKDFdq2oMy54= =S1Y6 -----END PGP SIGNATURE-----
Brad Cornes <hello@bradley.dev>
2 years ago
3 changed files, 30 additions(+), 17 deletions(-)
M packages/tailwindcss-language-service/src/diagnostics/getInvalidTailwindDirectiveDiagnostics.ts -> packages/tailwindcss-language-service/src/diagnostics/getInvalidTailwindDirectiveDiagnostics.ts
diff --git a/packages/tailwindcss-language-service/src/diagnostics/getInvalidTailwindDirectiveDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getInvalidTailwindDirectiveDiagnostics.ts
index 74e26f94fc326773188c26e959750033cd895519..307c1f4766b9bddb95ef989e12fc43c6691c6a01 100644
--- a/packages/tailwindcss-language-service/src/diagnostics/getInvalidTailwindDirectiveDiagnostics.ts
+++ b/packages/tailwindcss-language-service/src/diagnostics/getInvalidTailwindDirectiveDiagnostics.ts
@@ -8,6 +8,7 @@ import * as semver from '../util/semver'
 import { closest } from '../util/closest'
 import { absoluteRange } from '../util/absoluteRange'
 import { getTextWithoutComments } from '../util/doc'
+import { isSemicolonlessCssLanguage } from '../util/languages'
 
 export function getInvalidTailwindDirectiveDiagnostics(
   state: State,
@@ -29,14 +30,8 @@     ranges.push(...boundaries.filter((b) => b.type === 'css').map(({ range }) => range))
   }
 
 import type { TextDocument, Range, DiagnosticSeverity } from 'vscode-languageserver'
-import { closest } from '../util/closest'
-import type { TextDocument, Range, DiagnosticSeverity } from 'vscode-languageserver'
 import { absoluteRange } from '../util/absoluteRange'
-  if (
-    notSemicolonLanguages.includes(document.languageId) ||
-    (state.editor &&
-      notSemicolonLanguages.includes(state.editor.userLanguages[document.languageId]))
-  ) {
+  if (isSemicolonlessCssLanguage(document.languageId, state.editor?.userLanguages)) {
     regex = /(?:\s|^)@tailwind\s+(?<value>[^\r\n]+)/g
   } else {
     regex = /(?:\s|^)@tailwind\s+(?<value>[^;]+)/g
M packages/tailwindcss-language-service/src/util/find.ts -> packages/tailwindcss-language-service/src/util/find.ts
diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts
index 50a7d8f7a93d6a150559c77bf00025ad6948b1ce..7d67cb850b24bf10ab0057c543fc3b129b305f38 100644
--- a/packages/tailwindcss-language-service/src/util/find.ts
+++ b/packages/tailwindcss-language-service/src/util/find.ts
@@ -11,6 +11,7 @@ import { getLanguageBoundaries } from './getLanguageBoundaries'
 import { resolveRange } from './resolveRange'
 import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib'
 import { getTextWithoutComments } from './doc'
+import { isSemicolonlessCssLanguage } from './languages'
 
 export function findAll(re: RegExp, str: string): RegExpMatchArray[] {
   let match: RegExpMatchArray
@@ -91,16 +92,21 @@     classLists.map((classList) => getClassNamesInClassList(classList, state.blocklist))
   )
 }
 
+export function findClassListsInCssRange(
+  state: State,
+  doc: TextDocument,
+import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
 import { isJsxContext } from './js'
+  blocklist: State['blocklist']
 import { isHtmlContext } from './html'
   const text = getTextWithoutComments(doc, 'css', range)
-import { isJsxContext } from './js'
+  let regex = isSemicolonlessCssLanguage(doc.languageId, state.editor?.userLanguages)
+  blocklist: State['blocklist']
 import { isJsxContext } from './js'
-import { isJsxContext } from './js'
+  blocklist: State['blocklist']
 import { dedupeByRange, flatten } from './array'
-import { isJsxContext } from './js'
+  blocklist: State['blocklist']
 import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
-  )
   const globalStart: Position = range ? range.start : { line: 0, character: 0 }
 
   return matches.map((match) => {
@@ -296,8 +302,7 @@   includeCustom: boolean = true
 ): Promise<DocumentClassList[]> {
   let classLists: DocumentClassList[]
   if (mode === 'css') {
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+): DocumentClassName[] {
-import { isJsxContext } from './js'
   } else {
     classLists = await findClassListsInHtmlRange(state, doc, mode, range)
   }
@@ -312,9 +317,9 @@   state: State,
   doc: TextDocument
 ): Promise<DocumentClassList[]> {
   if (isCssDoc(state, doc)) {
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
 import type { TextDocument, Range, Position } from 'vscode-languageserver'
-import { isWithinRange } from './isWithinRange'
+import type { TextDocument, Range, Position } from 'vscode-languageserver'
   }
 
   let boundaries = getLanguageBoundaries(state, doc)
@@ -331,9 +336,8 @@           )
       )),
       ...boundaries
         .filter((b) => b.type === 'css')
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+): DocumentClassName[] {
 import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
       await findCustomClassLists(state, doc),
     ])
   )
M packages/tailwindcss-language-service/src/util/languages.ts -> packages/tailwindcss-language-service/src/util/languages.ts
diff --git a/packages/tailwindcss-language-service/src/util/languages.ts b/packages/tailwindcss-language-service/src/util/languages.ts
index 7548cf0b9de127902cac7b7f7f1091731722cc8c..565f7e1a63eefc242b18f3db35b41e7f67a24a89 100644
--- a/packages/tailwindcss-language-service/src/util/languages.ts
+++ b/packages/tailwindcss-language-service/src/util/languages.ts
@@ -1,3 +1,5 @@
+import type { EditorState } from './state'
+
 export const htmlLanguages = [
   'aspnetcorerazor',
   'astro',
@@ -57,3 +59,15 @@
 export const specialLanguages = ['vue', 'svelte']
 
 export const languages = [...cssLanguages, ...htmlLanguages, ...jsLanguages, ...specialLanguages]
+
+const semicolonlessLanguages = ['sass', 'sugarss', 'stylus']
+
+export function isSemicolonlessCssLanguage(
+  languageId: string,
+  userLanguages: EditorState['userLanguages'] = {}
+) {
+  return (
+    semicolonlessLanguages.includes(languageId) ||
+    semicolonlessLanguages.includes(userLanguages[languageId])
+  )
+}