[autocomplete] use parserlib's list of CSS props
This commit is contained in:
parent
9022f6b318
commit
40ec2c000f
|
@ -12,7 +12,7 @@
|
||||||
const USO_VAR = 'uso-variable';
|
const USO_VAR = 'uso-variable';
|
||||||
const USO_VALID_VAR = 'variable-3 ' + USO_VAR;
|
const USO_VALID_VAR = 'variable-3 ' + USO_VAR;
|
||||||
const USO_INVALID_VAR = 'error ' + USO_VAR;
|
const USO_INVALID_VAR = 'error ' + USO_VAR;
|
||||||
const rxPROP = /^(prop(erty)?|variable-2)\b/;
|
const rxPROP = /^(prop(erty)?|variable-2|string-2)\b/;
|
||||||
const rxVAR = /(^|[^-.\w\u0080-\uFFFF])var\(/iyu;
|
const rxVAR = /(^|[^-.\w\u0080-\uFFFF])var\(/iyu;
|
||||||
const rxCONSUME = /([-\w]*\s*:\s?)?/yu;
|
const rxCONSUME = /([-\w]*\s*:\s?)?/yu;
|
||||||
const cssMime = CodeMirror.mimeModes['text/css'];
|
const cssMime = CodeMirror.mimeModes['text/css'];
|
||||||
|
@ -142,8 +142,8 @@
|
||||||
leftLC = leftLC.replace(/^[^\w\s]\s*/, '');
|
leftLC = leftLC.replace(/^[^\w\s]\s*/, '');
|
||||||
}
|
}
|
||||||
if (prop.startsWith('--')) prop = 'color'; // assuming 90% of variables are colors
|
if (prop.startsWith('--')) prop = 'color'; // assuming 90% of variables are colors
|
||||||
if (!cssValues) cssValues = await linterMan.worker.getCssPropsValues();
|
if (!cssProps) await initCssProps();
|
||||||
list = [...new Set([...cssValues.own[prop] || [], ...cssValues.global])];
|
list = [...new Set([...cssValues.all[prop] || [], ...cssValues.global])];
|
||||||
end = prev + execAt(/(\s*[-a-z(]+)?/y, prev, text)[0].length;
|
end = prev + execAt(/(\s*[-a-z(]+)?/y, prev, text)[0].length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
if (!list &&
|
if (!list &&
|
||||||
/^(prop(erty|\?)|atom|error|tag)/.test(type) &&
|
/^(prop(erty|\?)|atom|error|tag)/.test(type) &&
|
||||||
/^(block|atBlock_parens|maybeprop)/.test(getTokenState())) {
|
/^(block|atBlock_parens|maybeprop)/.test(getTokenState())) {
|
||||||
if (!cssProps) initCssProps();
|
if (!cssProps) await initCssProps();
|
||||||
if (type === 'prop?') {
|
if (type === 'prop?') {
|
||||||
prev += leftLC.length;
|
prev += leftLC.length;
|
||||||
leftLC = '';
|
leftLC = '';
|
||||||
|
@ -174,8 +174,9 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function initCssProps() {
|
async function initCssProps() {
|
||||||
cssProps = addSuffix(cssMime.propertyKeywords);
|
cssValues = await linterMan.worker.getCssPropsValues();
|
||||||
|
cssProps = addSuffix(cssValues.all);
|
||||||
cssMedia = [].concat(...Object.entries(cssMime).map(getMediaKeys).filter(Boolean)).sort();
|
cssMedia = [].concat(...Object.entries(cssMime).map(getMediaKeys).filter(Boolean)).sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
// moving vendor-prefixed props to the end
|
// moving vendor-prefixed props to the end
|
||||||
const cmp = (a, b) => a[0] === '-' && b[0] !== '-' ? 1 : a < b ? -1 : a > b;
|
const cmp = (a, b) => a[0] === '-' && b[0] !== '-' ? 1 : a < b ? -1 : a > b;
|
||||||
for (const [k, v] of Object.entries(Properties)) {
|
for (const [k, v] of Object.entries(Properties)) {
|
||||||
|
res[k] = false;
|
||||||
if (typeof v === 'string') {
|
if (typeof v === 'string') {
|
||||||
let last = '';
|
let last = '';
|
||||||
const uniq = [];
|
const uniq = [];
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
if (uniq.length) res[k] = uniq;
|
if (uniq.length) res[k] = uniq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {own: res, global: GlobalKeywords};
|
return {all: res, global: GlobalKeywords};
|
||||||
},
|
},
|
||||||
|
|
||||||
getRules(linter) {
|
getRules(linter) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user