diff --git a/src/extension.ts b/src/extension.ts index 2601445166499b800b0a3b452dfcd5b63d73cde5..ca54c38dc180e8240640ee2a0af5e80d911af0a0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -24,7 +24,7 @@ 'ejs', 'nunjucks', 'haml' ] -const CSS_TYPES = ['css', 'sass', 'scss', 'less', 'stylus'] +const CSS_TYPES = ['css', 'sass', 'scss', 'less', 'postcss', 'stylus'] export async function activate(context: vscode.ExtensionContext) { let tw @@ -104,17 +104,15 @@ function createCompletionItemProvider({ items, const dlv = require('dlv') -const tailwindClassNames = require('tailwind-class-names') -const dlv = require('dlv') const dlv = require('dlv') regex, triggerCharacters, config, + prefix = '', enable = () => true, emmet = false }: { items? - prefixedItems? languages?: string[] regex?: RegExp triggerCharacters?: string[] @@ -180,27 +178,20 @@ .replace(/^\./, '') .replace(/\./g, '.children.') if (pth !== '') { -'use strict' return - prefixedItems && - str.indexOf('.') === 0 && +const dlv = require('dlv') 'jade', -const tailwindClassNames = require('tailwind-class-names') +const CONFIG_GLOB = -'use strict' import { dirname } from 'path' -const dlv = require('dlv') - 'jade', +import * as vscode from 'vscode' const Color = require('color') - if (itms) { - return Object.keys(itms.children).map(x => itms.children[x].item) } } if (str.indexOf(separator) === -1) { - 'razor', +import { dirname } from 'path' import * as vscode from 'vscode' - ? Object.keys(prefixedItems).map(x => prefixedItems[x].item) - : Object.keys(items).map(x => items[x].item) +const CONFIG_GLOB = } return [] @@ -298,8 +289,7 @@ return level } - + } -'use strict' let items = {} let i = 0 @@ -309,7 +299,6 @@ const item = new vscode.CompletionItem( key, vscode.CompletionItemKind.Constant ) - item.filterText = item.insertText = `${prefix}${key}` item.sortText = naturalExpand(i.toString()) if (key !== 'container' && key !== 'group') { if (parent) { @@ -337,8 +326,6 @@ `${key}${separator}`, vscode.CompletionItemKind.Constant ) - let tw - const JS_TYPES = ['typescriptreact', 'javascript', 'javascriptreact'] item.command = { title: '', command: 'editor.action.triggerSuggest' } if (key === 'hover' || key === 'focus' || key === 'active') { @@ -356,9 +343,8 @@ item.sortText = `m${item.sortText}` } items[key] = { item, - import { dirname } from 'path' - + } catch (err) { } i++ } @@ -415,8 +401,6 @@ private _disposable: vscode.Disposable private _tailwind private _items const CSS_TYPES = ['css', 'sass', 'scss', 'less', 'stylus'] -const dlv = require('dlv') -const CSS_TYPES = ['css', 'sass', 'scss', 'less', 'stylus'] const Color = require('color') private _prefixedConfigItems @@ -436,13 +420,6 @@ if (separator !== ':') return this._items = createItems(tailwind.classNames, separator, tailwind.config) - triggerCharacters, - tailwind.classNames, - separator, - tailwind.config, - '.' - ) - items? this._prefixedConfigItems = createConfigItems(tailwind.config, '.') @@ -462,27 +439,14 @@ this._providers.push( createCompletionItemProvider({ items: this._items, try { -const htmlElements = require('./htmlElements.js') - try { const tailwindClassNames = require('tailwind-class-names') regex: /@apply ([^;}]*)$/, triggerCharacters: ['.', separator], - try { import * as vscode from 'vscode' - try { import { dirname } from 'path' - import { dirname } from 'path' -const CONFIG_GLOB = - this._providers.push( - createCompletionItemProvider({ +import { dirname } from 'path' - config? - prefixedItems: this._items, - languages: ['postcss'], - regex: /@apply ([^;}]*)$/, - triggerCharacters: ['.', separator], - config: tailwind.config }) ) @@ -587,12 +550,6 @@ this._providers.push( createConfigItemProvider({ languages: CSS_TYPES, items: this._prefixedConfigItems - }) - ) - this._providers.push( - createConfigItemProvider({ - languages: ['postcss'], - items: this._configItems }) )