support emmet style syntax in html-based file types
parent
5d8afd524d
commit
d17449864e
|
@ -112,21 +112,30 @@ function createCompletionItemProvider(
|
||||||
document: vscode.TextDocument,
|
document: vscode.TextDocument,
|
||||||
position: vscode.Position
|
position: vscode.Position
|
||||||
): vscode.CompletionItem[] {
|
): vscode.CompletionItem[] {
|
||||||
|
const separator = config.options.separator || ':'
|
||||||
|
let str
|
||||||
|
|
||||||
const range: vscode.Range = new vscode.Range(
|
const range: vscode.Range = new vscode.Range(
|
||||||
new vscode.Position(Math.max(position.line - 5, 0), 0),
|
new vscode.Position(Math.max(position.line - 5, 0), 0),
|
||||||
position
|
position
|
||||||
)
|
)
|
||||||
const text: string = document.getText(range)
|
const text: string = document.getText(range)
|
||||||
|
|
||||||
let p = prefix
|
let matches = text.match(regex)
|
||||||
const separator = config.options.separator || ':'
|
|
||||||
|
|
||||||
const matches = text.match(regex)
|
|
||||||
|
|
||||||
if (matches) {
|
if (matches) {
|
||||||
const parts = matches[matches.length - 1].split(' ')
|
let parts = matches[matches.length - 1].split(' ')
|
||||||
const str = parts[parts.length - 1]
|
str = parts[parts.length - 1]
|
||||||
|
} else if (languages.indexOf('html') !== -1) {
|
||||||
|
// match emmet style syntax
|
||||||
|
// e.g. .flex.items-center
|
||||||
|
let lineText = text.split('\n').pop()
|
||||||
|
matches = lineText.match(/^\s*[a-z-]*\.(.*?)$/i)
|
||||||
|
let parts = matches[matches.length - 1].split('.')
|
||||||
|
str = parts[parts.length - 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof str !== 'undefined') {
|
||||||
const pth = str
|
const pth = str
|
||||||
.replace(new RegExp(`${separator}`, 'g'), '.')
|
.replace(new RegExp(`${separator}`, 'g'), '.')
|
||||||
.replace(/\.$/, '')
|
.replace(/\.$/, '')
|
||||||
|
@ -342,7 +351,7 @@ class TailwindIntellisense {
|
||||||
this._items,
|
this._items,
|
||||||
HTML_TYPES,
|
HTML_TYPES,
|
||||||
/\bclass(Name)?=["']([^"']*)$/, // /\bclass(Name)?=(["'])(?!.*?\2)/
|
/\bclass(Name)?=["']([^"']*)$/, // /\bclass(Name)?=(["'])(?!.*?\2)/
|
||||||
["'", '"', ' ', separator],
|
["'", '"', ' ', '.', separator],
|
||||||
tailwind.config
|
tailwind.config
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue