tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
diff --git a/src/extension.ts b/src/extension.ts
index 106636556df4a168633afcc4e3689b563fe63fd9..434792823a14a7e10fb27668aea1e8a91b832ab4 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -6,135 +6,111 @@ const tailwindClassNames = require('tailwind-class-names')
// const tailwindClassNames = require('/Users/brad/Code/tailwind-class-names/dist')
const dlv = require('dlv')
+const CONFIG_GLOB = '{tailwind,tailwind.config,.tailwindrc}.js'
+
export async function activate(context: vscode.ExtensionContext) {
- if (!vscode.workspace.name) return
-'use strict'
- '{tailwind,tailwind.config,.tailwindrc}.js',
+
-'use strict'
'use strict'
-import * as vscode from 'vscode'
'use strict'
-import { join } from 'path'
+}
'use strict'
-const tailwindClassNames = require('tailwind-class-names')
+export function deactivate() {}
const plugin = join(
+ if (!vscode.workspace.name) return
vscode.workspace.workspaceFolders[0].uri.fsPath,
- 'node_modules',
+
'use strict'
- if (!vscode.workspace.name) return
+const dlv = require('dlv')
'use strict'
-import { join } from 'path'
- let tw
-
-
'use strict'
-
+const dlv = require('dlv')
-
+ vscode.workspace.workspaceFolders[0].uri.fsPath,
import * as vscode from 'vscode'
-
+ vscode.workspace.workspaceFolders[0].uri.fsPath,
import { join } from 'path'
+ vscode.workspace.workspaceFolders[0].uri.fsPath,
const tailwindClassNames = require('tailwind-class-names')
-
+ vscode.workspace.workspaceFolders[0].uri.fsPath,
// const tailwindClassNames = require('/Users/brad/Code/tailwind-class-names/dist')
-
+ vscode.workspace.workspaceFolders[0].uri.fsPath,
const dlv = require('dlv')
-
+ vscode.workspace.workspaceFolders[0].uri.fsPath,
export async function activate(context: vscode.ExtensionContext) {
-
+ vscode.workspace.workspaceFolders[0].uri.fsPath,
if (!vscode.workspace.name) return
-import * as vscode from 'vscode'
+ 'node_modules',
-import * as vscode from 'vscode'
'use strict'
-import * as vscode from 'vscode'
-
- const separator = dlv(tw.config, 'options.separator', ':')
+'use strict'
- if (separator !== ':') return
-
+ intellisense.reload(tw)
import * as vscode from 'vscode'
-const tailwindClassNames = require('tailwind-class-names')
-import * as vscode from 'vscode'
// const tailwindClassNames = require('/Users/brad/Code/tailwind-class-names/dist')
-import * as vscode from 'vscode'
const dlv = require('dlv')
- items,
- ['typescriptreact', 'javascript', 'javascriptreact'],
- /\btw`([^`]*)$/,
+
-import { join } from 'path'
'use strict'
-import { join } from 'path'
+export async function activate(context: vscode.ExtensionContext) {
-
if (!vscode.workspace.name) return
- )
+ 'node_modules',
import * as vscode from 'vscode'
-// const tailwindClassNames = require('/Users/brad/Code/tailwind-class-names/dist')
- createCompletionItemProvider(
+ CONFIG_GLOB,
- items,
+ '**/node_modules/**',
-import { join } from 'path'
+'use strict'
import * as vscode from 'vscode'
-import { join } from 'path'
+'use strict'
import { join } from 'path'
-import { join } from 'path'
+ 'node_modules',
const tailwindClassNames = require('tailwind-class-names')
- tw.config,
- '.'
- if (!vscode.workspace.name) return
'use strict'
-import { join } from 'path'
+ position
-import * as vscode from 'vscode'
+'use strict'
// const tailwindClassNames = require('/Users/brad/Code/tailwind-class-names/dist')
-import * as vscode from 'vscode'
+'use strict'
const dlv = require('dlv')
-import * as vscode from 'vscode'
+'use strict'
export async function activate(context: vscode.ExtensionContext) {
- [
+ 'tailwindcss'
+'use strict'
import { join } from 'path'
- if (!vscode.workspace.name) return
-const tailwindClassNames = require('tailwind-class-names')
+
+
-const tailwindClassNames = require('tailwind-class-names')
+
+
'use strict'
-const tailwindClassNames = require('tailwind-class-names')
+
- 'blade',
+ configPath,
-const tailwindClassNames = require('tailwind-class-names')
+
import { join } from 'path'
-const tailwindClassNames = require('tailwind-class-names')
+
const tailwindClassNames = require('tailwind-class-names')
-const tailwindClassNames = require('tailwind-class-names')
+
// const tailwindClassNames = require('/Users/brad/Code/tailwind-class-names/dist')
-const tailwindClassNames = require('tailwind-class-names')
+
const dlv = require('dlv')
-const tailwindClassNames = require('tailwind-class-names')
+
export async function activate(context: vscode.ExtensionContext) {
-const tailwindClassNames = require('tailwind-class-names')
+
if (!vscode.workspace.name) return
-// const tailwindClassNames = require('/Users/brad/Code/tailwind-class-names/dist')
+import * as vscode from 'vscode'
-// const tailwindClassNames = require('/Users/brad/Code/tailwind-class-names/dist')
'use strict'
- 'javascript',
+ const text: string = document.getText(range)
-// const tailwindClassNames = require('/Users/brad/Code/tailwind-class-names/dist')
import * as vscode from 'vscode'
- ],
- /\bclass(Name)?=["']([^"']*)/, // /\bclass(Name)?=(["'])(?!.*?\2)/
- ["'", '"', ' ', separator],
-import { join } from 'path'
- if (!vscode.workspace.name) return
'use strict'
-import { join } from 'path'
+ let p = prefix
}
export function deactivate() {}
@@ -247,8 +223,6 @@ item
}
} else {
'use strict'
- 'razor',
-'use strict'
createCompletionItemProvider(
`${key}${separator}`,
vscode.CompletionItemKind.Constant
@@ -273,3 +247,82 @@ })
return items
}
+
+class TailwindIntellisense {
+ private _completionProviders: vscode.Disposable[]
+ private _disposable: vscode.Disposable
+ private _items
+
+ constructor(tailwind) {
+ if (tailwind) {
+ this.reload(tailwind)
+ }
+ }
+
+ public reload(tailwind) {
+ this.dispose()
+
+ const separator = dlv(tailwind.config, 'options.separator', ':')
+
+ if (separator !== ':') return
+
+ this._items = createItems(tailwind.classNames, separator, tailwind.config)
+
+ this._completionProviders = []
+
+ this._completionProviders.push(
+ createCompletionItemProvider(
+ this._items,
+ ['typescriptreact', 'javascript', 'javascriptreact'],
+ /\btw`([^`]*)$/,
+ ['`', ' ', separator],
+ tailwind.config
+ )
+ )
+
+ this._completionProviders.push(
+ createCompletionItemProvider(
+ this._items,
+ ['css', 'sass', 'scss'],
+ /@apply ([^;}]*)$/,
+ ['.', separator],
+ tailwind.config,
+ '.'
+ )
+ )
+
+ this._completionProviders.push(
+ createCompletionItemProvider(
+ this._items,
+ [
+ 'html',
+ 'jade',
+ 'razor',
+ 'php',
+ 'blade',
+ 'vue',
+ 'twig',
+ 'markdown',
+ 'erb',
+ 'handlebars',
+ 'ejs',
+ // for jsx
+ 'typescriptreact',
+ 'javascript',
+ 'javascriptreact'
+ ],
+ /\bclass(Name)?=["']([^"']*)/, // /\bclass(Name)?=(["'])(?!.*?\2)/
+ ["'", '"', ' ', separator],
+ tailwind.config
+ )
+ )
+
+ this._disposable = vscode.Disposable.from(...this._completionProviders)
+ }
+
+ dispose() {
+ if (this._disposable) {
+ this._disposable.dispose()
+ }
+ }
+}