Skip to content

Commit

Permalink
Merge de3e39f into 1f2eb25
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Feb 20, 2020
2 parents 1f2eb25 + de3e39f commit b649adf
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 20 deletions.
58 changes: 51 additions & 7 deletions cspell.schema.json
Expand Up @@ -3,23 +3,33 @@
"additionalProperties": false,
"definitions": {
"DictionaryDefinition": {
"anyOf": [
{
"$ref": "#/definitions/DictionaryDefinitionPreferred"
},
{
"$ref": "#/definitions/DictionaryDefinitionLegacy"
}
]
},
"DictionaryDefinitionLegacy": {
"additionalProperties": false,
"properties": {
"description": {
"description": "Optional description",
"type": "string"
},
"file": {
"description": "File name",
"type": "string"
"$ref": "#/definitions/FsPath",
"description": "File name @deprecated use path"
},
"name": {
"$ref": "#/definitions/DictionaryId",
"description": "The reference name of the dictionary, used with program language settings"
},
"path": {
"description": "Path to the file, if undefined the path to the extension dictionaries is assumed",
"type": "string"
"$ref": "#/definitions/FsPath",
"description": "Path to the file, if undefined the path to the extension dictionaries is assumed"
},
"repMap": {
"$ref": "#/definitions/ReplaceMap",
Expand All @@ -35,9 +45,39 @@
"type": "boolean"
}
},
"required": [
"file",
"name"
],
"type": "object"
},
"DictionaryDefinitionPreferred": {
"additionalProperties": false,
"properties": {
"description": {
"description": "Optional description",
"type": "string"
},
"name": {
"$ref": "#/definitions/DictionaryId",
"description": "The reference name of the dictionary, used with program language settings"
},
"path": {
"$ref": "#/definitions/FsPath",
"description": "Path to the file, if undefined the path to the extension dictionaries is assumed"
},
"repMap": {
"$ref": "#/definitions/ReplaceMap",
"description": "Replacement pairs"
},
"useCompounds": {
"description": "Use Compounds",
"type": "boolean"
}
},
"required": [
"name",
"file"
"path"
],
"type": "object"
},
Expand All @@ -54,6 +94,10 @@
"description": "This matches the name in a dictionary definition",
"type": "string"
},
"FsPath": {
"description": "A File System Path",
"type": "string"
},
"Glob": {
"description": "These are glob expressions",
"type": "string"
Expand Down Expand Up @@ -490,11 +534,11 @@
"import": {
"anyOf": [
{
"type": "string"
"$ref": "#/definitions/FsPath"
},
{
"items": {
"type": "string"
"$ref": "#/definitions/FsPath"
},
"type": "array"
}
Expand Down
34 changes: 25 additions & 9 deletions packages/cspell-lib/src/Settings/CSpellSettingsDef.ts
Expand Up @@ -28,7 +28,7 @@ export interface FileSettings extends ExtendableSettings {
userWords?: string[];

/** Other settings files to be included */
import?: string | string[];
import?: FsPath | FsPath[];
}

export interface ExtendableSettings extends Settings {
Expand Down Expand Up @@ -177,15 +177,32 @@ export interface BaseSetting {

export type DictionaryFileTypes = 'S'|'W'|'C'|'T';

export interface DictionaryDefinition {
export type DictionaryDefinition = DictionaryDefinitionPreferred | DictionaryDefinitionLegacy;

export interface DictionaryDefinitionBase {
/** The reference name of the dictionary, used with program language settings */
name: DictionaryId;
/** Optional description */
description?: string;
/** Replacement pairs */
repMap?: ReplaceMap;
/** Use Compounds */
useCompounds?: boolean;
}

export interface DictionaryDefinitionPreferred extends DictionaryDefinitionBase {
/** Path to the file, if undefined the path to the extension dictionaries is assumed */
path?: string;
/** File name */
file: string;
path: FsPath;
}

/**
* @deprecated
*/
export interface DictionaryDefinitionLegacy extends DictionaryDefinitionBase {
/** Path to the file, if undefined the path to the extension dictionaries is assumed */
path?: FsPath;
/** File name @deprecated use path */
file: FsPath;
/**
* Type of file:
* S - single word per line,
Expand All @@ -196,10 +213,6 @@ export interface DictionaryDefinition {
* @default "S"
*/
type?: DictionaryFileTypes;
/** Replacement pairs */
repMap?: ReplaceMap;
/** Use Compounds */
useCompounds?: boolean;
}

export interface LanguageSetting extends LanguageSettingFilterFields, BaseSetting {
Expand Down Expand Up @@ -254,6 +267,9 @@ export type Glob = string;
/** This can be '*', 'typescript', 'cpp', 'json', etc. */
export type LanguageId = string;

/** A File System Path */
export type FsPath = string;

export interface RegExpPatternDefinition {
/**
* Pattern name, used as an identifier in ignoreRegExpList and includeRegExpList
Expand Down
7 changes: 3 additions & 4 deletions packages/cspell-lib/src/Settings/DictionarySettings.ts
@@ -1,4 +1,4 @@
import { DictionaryDefinition, DictionaryId } from './CSpellSettingsDef';
import { DictionaryDefinition, DictionaryId, DictionaryDefinitionLegacy } from './CSpellSettingsDef';
import * as path from 'path';
import * as os from 'os';

Expand Down Expand Up @@ -29,8 +29,8 @@ export function filterDictDefsToLoad(dictIds: DictionaryId[], defs: DictionaryDe
}

function getFullPathName(def: DictionaryDefinition) {
const { path: filePath = '', file = '' } = def;
if (filePath + file === '') {
const { path: filePath = '', file = '' } = def as DictionaryDefinitionLegacy;
if (!filePath && !file) {
return '';
}
const dictPath = path.join(filePath || dictionaryPath(), file);
Expand All @@ -50,4 +50,3 @@ export function normalizePathForDictDef(def: DictionaryDefinition, defaultPath:
path: absPath.replace(/^~/, os.homedir())
};
}

0 comments on commit b649adf

Please sign in to comment.