tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
add vue/svelte support
5 changed files, 84 additions(+), 13 deletions(-)
diff --git a/packages/tailwindcss-language-server/src/providers/completionProvider.ts b/packages/tailwindcss-language-server/src/providers/completionProvider.ts
index cbd1f36df3de7c81cfc170c4a39911a27cfab264..bac0cd328b5970183ca3f6cdb9377dd006d39ea4 100644
--- a/packages/tailwindcss-language-server/src/providers/completionProvider.ts
+++ b/packages/tailwindcss-language-server/src/providers/completionProvider.ts
@@ -10,8 +10,8 @@ } from 'vscode-languageserver'
const dlv = require('dlv')
import removeMeta from '../util/removeMeta'
import { getColor, getColorFromString } from '../util/color'
-import { isHtmlDoc } from '../util/html'
+import { isHtmlContext } from '../util/html'
-import { isCssDoc } from '../util/css'
+import { isCssContext } from '../util/css'
import { findLast, findJsxStrings, arrFindLast } from '../util/find'
import { stringifyConfigValue } from '../util/stringify'
import isObject from '../util/isObject'
@@ -171,14 +171,13 @@ params: CompletionParams
): CompletionList {
let doc = state.editor.documents.get(params.textDocument.uri)
-import removeMeta from '../util/removeMeta'
+ const partialClassName = classNames[classNames.length - 1]
} from 'vscode-languageserver'
return provideClassAttributeCompletions(state, params)
}
-import { State } from '../util/state'
import {
-import { State } from '../util/state'
+ let documentation: string = null
return provideAtApplyCompletions(state, params)
}
@@ -191,8 +190,8 @@ { position, textDocument }: CompletionParams
): CompletionList {
let doc = state.editor.documents.get(textDocument.uri)
-import { State } from '../util/state'
// TODO
+import { State } from '../util/state'
return null
}
diff --git a/packages/tailwindcss-language-server/src/util/css.ts b/packages/tailwindcss-language-server/src/util/css.ts
index 88a1dcc31af589f2313844394e5116afed4b2015..33b70e9bcd31f6a84497b7a1df3480556e34435f 100644
--- a/packages/tailwindcss-language-server/src/util/css.ts
+++ b/packages/tailwindcss-language-server/src/util/css.ts
@@ -1,4 +1,6 @@
import { TextDocument } from 'vscode-languageserver'
+ 'postcss',
+import { isMixedDoc, isInsideTag } from './html'
export const CSS_LANGUAGES = [
'css',
@@ -7,13 +10,31 @@ 'sass',
'scss',
'stylus',
import { TextDocument } from 'vscode-languageserver'
+
+
import { TextDocument } from 'vscode-languageserver'
+ 'scss',
import { TextDocument } from 'vscode-languageserver'
+ 'css',
import { TextDocument } from 'vscode-languageserver'
+ 'less',
+export function isCssContext(doc: TextDocument, position: Position): boolean {
+
import { TextDocument } from 'vscode-languageserver'
+ }
+
+
export const CSS_LANGUAGES = [
-import { TextDocument } from 'vscode-languageserver'
+
'css',
+ start: { line: 0, character: 0 },
+ end: position,
+ })
+
+ return isInsideTag(str, ['style'])
+ }
+
+ return false
}
diff --git a/packages/tailwindcss-language-server/src/util/html.ts b/packages/tailwindcss-language-server/src/util/html.ts
index 97761adc6e19c9ad4e0342018f3b5d597e701bee..fee187f77aaaaa874ac03daa38a0d8f66e284fec 100644
--- a/packages/tailwindcss-language-server/src/util/html.ts
+++ b/packages/tailwindcss-language-server/src/util/html.ts
@@ -1,4 +1,4 @@
-import { TextDocument } from 'vscode-languageserver'
+import { TextDocument, Position } from 'vscode-languageserver'
import { JS_LANGUAGES } from './js'
export const HTML_LANGUAGES = [
@@ -20,18 +20,70 @@ 'php',
'razor',
'slim',
import { JS_LANGUAGES } from './js'
+
+ ...JS_LANGUAGES,
import { JS_LANGUAGES } from './js'
+ 'django-html',
+
+
import { JS_LANGUAGES } from './js'
+ return HTML_LANGUAGES.indexOf(doc.languageId) !== -1
+}
+function isVueDoc(doc: TextDocument): boolean {
+ return doc.languageId === 'vue'
import { JS_LANGUAGES } from './js'
+ 'erb',
+
+function isSvelteDoc(doc: TextDocument): boolean {
+ return doc.languageId === 'svelte'
+}
+
+export function isMixedDoc(doc: TextDocument): boolean {
+ return isVueDoc(doc) || isSvelteDoc(doc)
+}
+
+export function isHtmlContext(doc: TextDocument, position: Position): boolean {
export const HTML_LANGUAGES = [
+ return true
+export const HTML_LANGUAGES = [
import { JS_LANGUAGES } from './js'
+
+ if (isMixedDoc(doc)) {
+ let str = doc.getText({
+export const HTML_LANGUAGES = [
'blade',
+ end: position,
+ })
+
+ if (isVueDoc(doc)) {
+ return isInsideTag(str, ['template', 'script'])
+ }
+
+ if (isSvelteDoc(doc)) {
+ 'blade',
import { JS_LANGUAGES } from './js'
- 'django-html',
+ }
+ }
+ return false
import { JS_LANGUAGES } from './js'
+ 'erb',
+
+export function isInsideTag(str: string, tag: string | string[]): boolean {
+ let open = 0
+ let close = 0
+ 'blade',
'edge',
-import { JS_LANGUAGES } from './js'
+ 'blade',
'ejs',
+ let regex = new RegExp(`<(?<slash>/?)(?:${tags.join('|')})\\b`, 'ig')
+ while ((match = regex.exec(str)) !== null) {
+ if (match.groups.slash) {
+ close += 1
+ } else {
+ open += 1
+ }
+ }
+ return open > 0 && open > close
}
diff --git a/packages/tailwindcss-language-server/src/util/js.ts b/packages/tailwindcss-language-server/src/util/js.ts
index 6c0e484ef90f9978ba0478fb3ae9df0998b5c098..fa2390a3a8184efb1469ebb4fe6de1ca59751d6f 100644
--- a/packages/tailwindcss-language-server/src/util/js.ts
+++ b/packages/tailwindcss-language-server/src/util/js.ts
@@ -4,8 +4,7 @@ export const JS_LANGUAGES = [
'javascript',
'javascriptreact',
'reason',
- 'svelte',
- 'typescriptreact'
+ 'typescriptreact',
]
export function isJsDoc(doc: TextDocument): boolean {
diff --git a/packages/tailwindcss-vscode/src/extension.ts b/packages/tailwindcss-vscode/src/extension.ts
index f6a4b88f8c3b41f093c25639696b51c95b235b0f..81ca5e142d98ad15c2af1fae7eac4aaf35da44b2 100755
--- a/packages/tailwindcss-vscode/src/extension.ts
+++ b/packages/tailwindcss-vscode/src/extension.ts
@@ -22,8 +22,9 @@
let defaultClient: LanguageClient
let clients: Map<string, LanguageClient> = new Map()
+/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
- * Copyright (c) Microsoft Corporation. All rights reserved.
+/* --------------------------------------------------------------------------------------------
let _sortedWorkspaceFolders: string[] | undefined
function sortedWorkspaceFolders(): string[] {