This commit is contained in:
Pine Wu 2019-08-27 09:25:15 -07:00
parent 04d52502b8
commit 739ae7737a
6 changed files with 80 additions and 4 deletions

View file

@ -7,6 +7,7 @@ import * as path from 'path';
import { workspace, WorkspaceFolder, extensions } from 'vscode';
interface ExperimentalConfig {
customData?: string[];
experimental?: {
customData?: string[];
};
@ -19,6 +20,21 @@ export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFol
return dataPaths;
}
workspaceFolders.forEach(wf => {
const allCssConfig = workspace.getConfiguration(undefined, wf.uri);
const wfCSSConfig = allCssConfig.inspect<ExperimentalConfig>('css');
if (wfCSSConfig && wfCSSConfig.workspaceFolderValue && wfCSSConfig.workspaceFolderValue.customData) {
const customData = wfCSSConfig.workspaceFolderValue.customData;
if (Array.isArray(customData)) {
customData.forEach(t => {
if (typeof t === 'string') {
dataPaths.push(path.resolve(wf.uri.fsPath, t));
}
});
}
}
});
workspaceFolders.forEach(wf => {
const allCssConfig = workspace.getConfiguration(undefined, wf.uri);
const wfCSSConfig = allCssConfig.inspect<ExperimentalConfig>('css');
@ -48,7 +64,20 @@ export function getCustomDataPathsFromAllExtensions(): string[] {
for (const extension of extensions.all) {
const contributes = extension.packageJSON && extension.packageJSON.contributes;
if (contributes && contributes.css && contributes.css.experimental.customData && Array.isArray(contributes.css.experimental.customData)) {
if (contributes && contributes.css && contributes.css.customData && Array.isArray(contributes.css.customData)) {
const relativePaths: string[] = contributes.css.customData;
relativePaths.forEach(rp => {
dataPaths.push(path.resolve(extension.extensionPath, rp));
});
}
if (
contributes &&
contributes.css &&
contributes.experimental &&
contributes.css.experimental.customData &&
Array.isArray(contributes.css.experimental.customData)
) {
const relativePaths: string[] = contributes.css.experimental.customData;
relativePaths.forEach(rp => {
dataPaths.push(path.resolve(extension.extensionPath, rp));

View file

@ -34,6 +34,15 @@
"id": "css",
"title": "%css.title%",
"properties": {
"css.customData": {
"type": "array",
"description": "%css.customData.desc%",
"default": [],
"items": {
"type": "string"
},
"scope": "resource"
},
"css.experimental.customData": {
"type": "array",
"description": "A list of JSON file paths that define custom CSS data that loads custom properties, at directives, pseudo classes / elements.",
@ -41,7 +50,8 @@
"items": {
"type": "string"
},
"scope": "resource"
"scope": "resource",
"deprecationMessage": "This setting is no longe experimental. Use `css.customData` instead."
},
"css.completion.triggerPropertyValueCompletion": {
"type": "boolean",

View file

@ -2,6 +2,7 @@
"displayName": "CSS Language Features",
"description": "Provides rich language support for CSS, LESS and SCSS files.",
"css.title": "CSS",
"css.customData.desc": "A list of JSON file paths that define custom CSS data that loads custom properties, at directives, pseudo classes / elements.",
"css.completion.triggerPropertyValueCompletion.desc": "By default, VS Code triggers property value completion after selecting a CSS property. Use this setting to disable this behavior.",
"css.lint.argumentsInColorFunction.desc": "Invalid number of parameters.",
"css.lint.boxModel.desc": "Do not use `width` or `height` when using `padding` or `border`.",

View file

@ -7,6 +7,7 @@ import * as path from 'path';
import { workspace, WorkspaceFolder, extensions } from 'vscode';
interface ExperimentalConfig {
customData?: string[];
experimental?: {
customData?: string[];
};
@ -23,6 +24,17 @@ export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFol
const allHtmlConfig = workspace.getConfiguration(undefined, wf.uri);
const wfHtmlConfig = allHtmlConfig.inspect<ExperimentalConfig>('html');
if (wfHtmlConfig && wfHtmlConfig.workspaceFolderValue && wfHtmlConfig.workspaceFolderValue.customData) {
const customData = wfHtmlConfig.workspaceFolderValue.customData;
if (Array.isArray(customData)) {
customData.forEach(t => {
if (typeof t === 'string') {
dataPaths.push(path.resolve(wf.uri.fsPath, t));
}
});
}
}
if (
wfHtmlConfig &&
wfHtmlConfig.workspaceFolderValue &&
@ -52,6 +64,19 @@ export function getCustomDataPathsFromAllExtensions(): string[] {
if (
contributes &&
contributes.html &&
contributes.html.customData &&
Array.isArray(contributes.html.customData)
) {
const relativePaths: string[] = contributes.html.customData;
relativePaths.forEach(rp => {
dataPaths.push(path.resolve(extension.extensionPath, rp));
});
}
if (
contributes &&
contributes.html &&
contributes.html.experimental &&
contributes.html.experimental.customData &&
Array.isArray(contributes.html.experimental.customData)
) {

View file

@ -32,6 +32,15 @@
"type": "object",
"title": "HTML",
"properties": {
"html.customData": {
"type": "array",
"description": "%html.customData.desc%",
"default": [],
"items": {
"type": "string"
},
"scope": "resource"
},
"html.experimental.customData": {
"type": "array",
"description": "A list of JSON file paths that define custom tags, properties and other HTML syntax constructs. Only workspace folder setting will be read.",
@ -39,7 +48,8 @@
"items": {
"type": "string"
},
"scope": "resource"
"scope": "resource",
"deprecationMessage": "This setting is no longe experimental. Use `html.customData` instead."
},
"html.format.enable": {
"type": "boolean",

View file

@ -1,6 +1,7 @@
{
"displayName": "HTML Language Features",
"description": "Provides rich language support for HTML and Handlebar files",
"html.customData.desc": "A list of JSON file paths that define custom tags, properties and other HTML syntax constructs. Only workspace folder setting will be read.",
"html.format.enable.desc": "Enable/disable default HTML formatter.",
"html.format.wrapLineLength.desc": "Maximum amount of characters per line (0 = disable).",
"html.format.unformatted.desc": "List of tags, comma separated, that shouldn't be reformatted. `null` defaults to all tags listed at https://www.w3.org/TR/html5/dom.html#phrasing-content.",
@ -24,4 +25,4 @@
"html.validate.scripts": "Controls whether the built-in HTML language support validates embedded scripts.",
"html.validate.styles": "Controls whether the built-in HTML language support validates embedded styles.",
"html.autoClosingTags": "Enable/disable autoclosing of HTML tags."
}
}