Skip to content

Commit

Permalink
fix: Update list of supported language Ids (#2796)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Sep 12, 2023
1 parent 760708b commit e169d64
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/_includes/generated-docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,6 @@ Description
: Specify a list of file types to spell check. It is better to use `#cSpell.enableFiletypes#` to Enable / Disable checking files types.

Default
: [ _`"asciidoc"`_, _`"c"`_, _`"cpp"`_, _`"csharp"`_, _`"css"`_, _`"elixir"`_, _`"erlang"`_, _`"git-commit"`_, _`"go"`_, _`"graphql"`_, _`"handlebars"`_, _`"haskell"`_, _`"html"`_, _`"jade"`_, _`"java"`_, _`"javascript"`_, _`"javascriptreact"`_, _`"json"`_, _`"jsonc"`_, _`"jupyter"`_, _`"latex"`_, _`"less"`_, _`"markdown"`_, _`"php"`_, _`"plaintext"`_, _`"python"`_, _`"pug"`_, _`"restructuredtext"`_, _`"rust"`_, _`"scala"`_, _`"scss"`_, _`"scminput"`_, _`"swift"`_, _`"text"`_, _`"typescript"`_, _`"typescriptreact"`_, _`"vue"`_, _`"yaml"`_, _`"yml"`_ ]
: [ _`"asciidoc"`_, _`"bat"`_, _`"c"`_, _`"clojure"`_, _`"coffeescript"`_, _`"cpp"`_, _`"csharp"`_, _`"css"`_, _`"dart"`_, _`"diff"`_, _`"dockerfile"`_, _`"elixir"`_, _`"erlang"`_, _`"fsharp"`_, _`"git-commit"`_, _`"git-rebase"`_, _`"github-actions-workflow"`_, _`"go"`_, _`"graphql"`_, _`"groovy"`_, _`"handlebars"`_, _`"haskell"`_, _`"html"`_, _`"ini"`_, _`"jade"`_, _`"java"`_, _`"javascript"`_, _`"javascriptreact"`_, _`"json"`_, _`"jsonc"`_, _`"julia"`_, _`"jupyter"`_, _`"latex"`_, _`"less"`_, _`"lua"`_, _`"makefile"`_, _`"markdown"`_, _`"objective-c"`_, _`"perl"`_, _`"perl6"`_, _`"php"`_, _`"plaintext"`_, _`"powershell"`_, _`"properties"`_, _`"pug"`_, _`"python"`_, _`"r"`_, _`"razor"`_, _`"restructuredtext"`_, _`"ruby"`_, _`"rust"`_, _`"scala"`_, _`"scminput"`_, _`"scss"`_, _`"shaderlab"`_, _`"shellscript"`_, _`"sql"`_, _`"swift"`_, _`"text"`_, _`"typescript"`_, _`"typescriptreact"`_, _`"vb"`_, _`"vue"`_, _`"xml"`_, _`"xsl"`_, _`"yaml"`_ ]

---
35 changes: 31 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2267,44 +2267,71 @@
"cSpell.enabledLanguageIds": {
"default": [
"asciidoc",
"bat",
"c",
"clojure",
"coffeescript",
"cpp",
"csharp",
"css",
"dart",
"diff",
"dockerfile",
"elixir",
"erlang",
"fsharp",
"git-commit",
"git-rebase",
"github-actions-workflow",
"go",
"graphql",
"groovy",
"handlebars",
"haskell",
"html",
"ini",
"jade",
"java",
"javascript",
"javascriptreact",
"json",
"jsonc",
"julia",
"jupyter",
"latex",
"less",
"lua",
"makefile",
"markdown",
"objective-c",
"perl",
"perl6",
"php",
"plaintext",
"python",
"powershell",
"properties",
"pug",
"python",
"r",
"razor",
"restructuredtext",
"ruby",
"rust",
"scala",
"scss",
"scminput",
"scss",
"shaderlab",
"shellscript",
"sql",
"swift",
"text",
"typescript",
"typescriptreact",
"vb",
"vue",
"yaml",
"yml"
"xml",
"xsl",
"yaml"
],
"items": {
"markdownDescription": "This can be '*', 'typescript', 'cpp', 'json', etc.",
Expand Down
35 changes: 31 additions & 4 deletions packages/_server/spell-checker-config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1927,44 +1927,71 @@
"cSpell.enabledLanguageIds": {
"default": [
"asciidoc",
"bat",
"c",
"clojure",
"coffeescript",
"cpp",
"csharp",
"css",
"dart",
"diff",
"dockerfile",
"elixir",
"erlang",
"fsharp",
"git-commit",
"git-rebase",
"github-actions-workflow",
"go",
"graphql",
"groovy",
"handlebars",
"haskell",
"html",
"ini",
"jade",
"java",
"javascript",
"javascriptreact",
"json",
"jsonc",
"julia",
"jupyter",
"latex",
"less",
"lua",
"makefile",
"markdown",
"objective-c",
"perl",
"perl6",
"php",
"plaintext",
"python",
"powershell",
"properties",
"pug",
"python",
"r",
"razor",
"restructuredtext",
"ruby",
"rust",
"scala",
"scss",
"scminput",
"scss",
"shaderlab",
"shellscript",
"sql",
"swift",
"text",
"typescript",
"typescriptreact",
"vb",
"vue",
"yaml",
"yml"
"xml",
"xsl",
"yaml"
],
"description": "Specify a list of file types to spell check. It is better to use `#cSpell.enableFiletypes#` to Enable / Disable checking files types.",
"items": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,44 +71,71 @@ export interface CSpellSettingsPackageProperties extends CSpellSettings {
* @uniqueItems true
* @default [
* "asciidoc",
* "bat",
* "c",
* "clojure",
* "coffeescript",
* "cpp",
* "csharp",
* "css",
* "dart",
* "diff",
* "dockerfile",
* "elixir",
* "erlang",
* "fsharp",
* "git-commit",
* "git-rebase",
* "github-actions-workflow",
* "go",
* "graphql",
* "groovy",
* "handlebars",
* "haskell",
* "html",
* "ini",
* "jade",
* "java",
* "javascript",
* "javascriptreact",
* "json",
* "jsonc",
* "julia",
* "jupyter",
* "latex",
* "less",
* "lua",
* "makefile",
* "markdown",
* "objective-c",
* "perl",
* "perl6",
* "php",
* "plaintext",
* "python",
* "powershell",
* "properties",
* "pug",
* "python",
* "r",
* "razor",
* "restructuredtext",
* "ruby",
* "rust",
* "scala",
* "scss",
* "scminput",
* "scss",
* "shaderlab",
* "shellscript",
* "sql",
* "swift",
* "text",
* "typescript",
* "typescriptreact",
* "vb",
* "vue",
* "yaml",
* "yml"
* "xml",
* "xsl",
* "yaml"
* ]
*/
enabledLanguageIds?: CSpellSettings['enabledLanguageIds'];
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class CSpellClient implements Disposable {
setOfSupportedSchemes.clear();
this.allowedSchemas.forEach((schema) => setOfSupportedSchemes.add(schema));

this.languageIds = new Set(languageIds.concat(enabledLanguageIds || []).concat(LanguageIds.languageIds));
this.languageIds = new Set([...languageIds, ...(enabledLanguageIds || []), ...LanguageIds.languageIds]);
const uniqueLangIds = [...this.languageIds];
const documentSelector = [...this.allowedSchemas]
.map((scheme) => uniqueLangIds.map((language) => ({ language, scheme })))
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/settings/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as index from './index';

describe('settings/index', () => {
test('', () => {
test('index', () => {
expect(typeof index.enableLocaleForTarget).toBe('function');
});
});
10 changes: 10 additions & 0 deletions packages/client/src/settings/languageIds.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { readDefaults } from '../test/schema';
import { languageIds } from './languageIds';

describe('settings/index', () => {
test('Default languageIds', async () => {
const defaultSettings = await readDefaults();
const enabled = defaultSettings.get('cSpell.enabledLanguageIds');
await expect([...languageIds].sort()).toEqual((Array.isArray(enabled) ? [...enabled] : [enabled]).sort());
});
});
10 changes: 10 additions & 0 deletions packages/client/src/settings/languageIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ export const languageIds: string[] = [
'fsharp',
'git-commit',
'git-rebase',
'github-actions-workflow', // .github/workflows/*.yaml files used to specify github workflows.
'go',
'graphql',
'groovy',
'handlebars',
'haskell',
'html',
'ini',
'jade',
'java',
'javascript',
'javascriptreact',
'json',
'jsonc',
'julia',
'jupyter',
'latex',
'less',
'lua',
'makefile',
Expand All @@ -41,13 +47,17 @@ export const languageIds: string[] = [
'python',
'r',
'razor',
'restructuredtext',
'ruby',
'rust',
'scala',
'scminput',
'scss',
'shaderlab',
'shellscript',
'sql',
'swift',
'text',
'typescript',
'typescriptreact',
'vb',
Expand Down
36 changes: 36 additions & 0 deletions packages/client/src/test/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { promises as fs } from 'node:fs';
import * as path from 'node:path';

export const schemaFile = path.join(__dirname, '../../../_server/spell-checker-config.schema.json');

export async function readExtensionSchema(): Promise<Item> {
const schema = await readJsonFile(schemaFile);
return schema;
}

async function readJsonFile(filename: string) {
return JSON.parse(await fs.readFile(filename, 'utf8'));
}

export async function readDefaults(): Promise<Map<string, unknown | undefined>> {
const schema = await readExtensionSchema();

const items = Array.isArray(schema.items) ? schema.items : schema.items ? [schema.items] : [];

const results = new Map<string, unknown | undefined>();

function processItem(item: Item) {
if (!item.properties) return;
Object.entries(item.properties).forEach(([k, v]) => results.set(k, v.default));
}

items.forEach((element) => processItem(element));

return results;
}

interface Item {
properties?: Record<string, Item>;
items?: Item | Item[];
default?: unknown;
}

0 comments on commit e169d64

Please sign in to comment.