Skip to content

Commit d174498

Browse files
committed
support emmet style syntax in html-based file types
1 parent 5d8afd5 commit d174498

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/extension.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,30 @@ function createCompletionItemProvider(
112112
document: vscode.TextDocument,
113113
position: vscode.Position
114114
): vscode.CompletionItem[] {
115+
const separator = config.options.separator || ':'
116+
let str
117+
115118
const range: vscode.Range = new vscode.Range(
116119
new vscode.Position(Math.max(position.line - 5, 0), 0),
117120
position
118121
)
119122
const text: string = document.getText(range)
120123

121-
let p = prefix
122-
const separator = config.options.separator || ':'
123-
124-
const matches = text.match(regex)
124+
let matches = text.match(regex)
125125

126126
if (matches) {
127-
const parts = matches[matches.length - 1].split(' ')
128-
const str = parts[parts.length - 1]
127+
let parts = matches[matches.length - 1].split(' ')
128+
str = parts[parts.length - 1]
129+
} else if (languages.indexOf('html') !== -1) {
130+
// match emmet style syntax
131+
// e.g. .flex.items-center
132+
let lineText = text.split('\n').pop()
133+
matches = lineText.match(/^\s*[a-z-]*\.(.*?)$/i)
134+
let parts = matches[matches.length - 1].split('.')
135+
str = parts[parts.length - 1]
136+
}
129137

138+
if (typeof str !== 'undefined') {
130139
const pth = str
131140
.replace(new RegExp(`${separator}`, 'g'), '.')
132141
.replace(/\.$/, '')
@@ -342,7 +351,7 @@ class TailwindIntellisense {
342351
this._items,
343352
HTML_TYPES,
344353
/\bclass(Name)?=["']([^"']*)$/, // /\bclass(Name)?=(["'])(?!.*?\2)/
345-
["'", '"', ' ', separator],
354+
["'", '"', ' ', '.', separator],
346355
tailwind.config
347356
)
348357
)

0 commit comments

Comments
 (0)