Skip to content

Commit c5813de

Browse files
authored
Merge pull request #53 from CodinGame/fix-files.eol-configuration
Fix files.eol configuration
2 parents 7f28141 + 2f16781 commit c5813de

File tree

3 files changed

+74
-55
lines changed

3 files changed

+74
-55
lines changed

src/configuration/files.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import * as monaco from 'monaco-editor'
2+
const configurationRegistry = monaco.extra.Registry.as<monaco.extra.IConfigurationRegistry>(monaco.extra.ConfigurationExtensions.Configuration)
3+
4+
/**
5+
* comes from https://github.com/microsoft/vscode/blob/16d0a319b28caa4b6cf4e6801fd508282b7533e0/src/vs/workbench/contrib/files/browser/files.contribution.ts#L132
6+
* files.exclude and files.associations are required by the Lua language server
7+
*/
8+
export const FILES_EXCLUDE_CONFIG = 'files.exclude'
9+
export const FILES_ASSOCIATIONS_CONFIG = 'files.associations'
10+
const isWeb = true
11+
const ConfigurationScope = monaco.extra.ConfigurationScope
12+
const nls = {
13+
localize: (key: string, defaultValue: string) => defaultValue
14+
}
15+
configurationRegistry.registerConfiguration({
16+
id: 'files',
17+
order: 9,
18+
title: 'Files',
19+
type: 'object',
20+
properties: {
21+
'files.eol': {
22+
type: 'string',
23+
enum: [
24+
'\n',
25+
'\r\n',
26+
'auto'
27+
],
28+
enumDescriptions: [
29+
nls.localize('eol.LF', 'LF'),
30+
nls.localize('eol.CRLF', 'CRLF'),
31+
nls.localize('eol.auto', 'Uses operating system specific end of line character.')
32+
],
33+
default: 'auto',
34+
description: nls.localize('eol', 'The default end of line character.'),
35+
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE
36+
},
37+
[FILES_EXCLUDE_CONFIG]: {
38+
type: 'object',
39+
markdownDescription: nls.localize('exclude', 'Configure glob patterns for excluding files and folders. For example, the file Explorer decides which files and folders to show or hide based on this setting. Refer to the `#search.exclude#` setting to define search specific excludes. Read more about glob patterns [here](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options).'),
40+
default: {
41+
...{ '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true, '**/Thumbs.db': true },
42+
...(isWeb as boolean ? { '**/*.crswap': true /* filter out swap files used for local file access */ } : undefined)
43+
},
44+
scope: ConfigurationScope.RESOURCE,
45+
additionalProperties: {
46+
anyOf: [
47+
{
48+
type: 'boolean',
49+
description: nls.localize('files.exclude.boolean', 'The glob pattern to match file paths against. Set to true or false to enable or disable the pattern.')
50+
},
51+
{
52+
type: 'object',
53+
properties: {
54+
when: {
55+
type: 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } })
56+
pattern: '\\w*\\$\\(basename\\)\\w*',
57+
default: '$(basename).ext',
58+
description: nls.localize('files.exclude.when', 'Additional check on the siblings of a matching file. Use $(basename) as variable for the matching file name.')
59+
}
60+
}
61+
}
62+
]
63+
}
64+
},
65+
[FILES_ASSOCIATIONS_CONFIG]: {
66+
type: 'object',
67+
markdownDescription: nls.localize('associations', 'Configure file associations to languages (e.g. `"*.extension": "html"`). These have precedence over the default associations of the languages installed.'),
68+
additionalProperties: {
69+
type: 'string'
70+
}
71+
}
72+
}
73+
})

src/configuration/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { IConfigurationChangeEvent, IConfigurationService } from 'vscode/service
33
import * as vscode from 'vscode'
44
import { updateUserConfiguration } from 'vscode/service-override/configuration'
55
import extensions from '../languages/extensions/extensions.json'
6+
import './files'
67

78
const configurationRegistry = monaco.extra.Registry.as<monaco.extra.IConfigurationRegistry>(monaco.extra.ConfigurationExtensions.Configuration)
89
configurationRegistry.registerDefaultConfigurations([{

src/features/extensionConfigurations.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,3 @@ export async function loadConfigurationForExtension (extensionId: string): Promi
1111
const configuration = await loader()
1212
configurationRegistry.registerConfigurations(configuration)
1313
}
14-
15-
/**
16-
* comes from https://github.com/microsoft/vscode/blob/16d0a319b28caa4b6cf4e6801fd508282b7533e0/src/vs/workbench/contrib/files/browser/files.contribution.ts#L132
17-
* Required by the Lua language server
18-
*/
19-
export const FILES_EXCLUDE_CONFIG = 'files.exclude'
20-
export const FILES_ASSOCIATIONS_CONFIG = 'files.associations'
21-
const isWeb = true
22-
const ConfigurationScope = monaco.extra.ConfigurationScope
23-
const nls = {
24-
localize: (key: string, defaultValue: string) => defaultValue
25-
}
26-
configurationRegistry.registerConfiguration({
27-
id: 'files',
28-
order: 9,
29-
title: 'Files',
30-
type: 'object',
31-
properties: {
32-
[FILES_EXCLUDE_CONFIG]: {
33-
type: 'object',
34-
markdownDescription: nls.localize('exclude', 'Configure glob patterns for excluding files and folders. For example, the file Explorer decides which files and folders to show or hide based on this setting. Refer to the `#search.exclude#` setting to define search specific excludes. Read more about glob patterns [here](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options).'),
35-
default: {
36-
...{ '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true, '**/Thumbs.db': true },
37-
...(isWeb as boolean ? { '**/*.crswap': true /* filter out swap files used for local file access */ } : undefined)
38-
},
39-
scope: ConfigurationScope.RESOURCE,
40-
additionalProperties: {
41-
anyOf: [
42-
{
43-
type: 'boolean',
44-
description: nls.localize('files.exclude.boolean', 'The glob pattern to match file paths against. Set to true or false to enable or disable the pattern.')
45-
},
46-
{
47-
type: 'object',
48-
properties: {
49-
when: {
50-
type: 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } })
51-
pattern: '\\w*\\$\\(basename\\)\\w*',
52-
default: '$(basename).ext',
53-
description: nls.localize('files.exclude.when', 'Additional check on the siblings of a matching file. Use $(basename) as variable for the matching file name.')
54-
}
55-
}
56-
}
57-
]
58-
}
59-
},
60-
[FILES_ASSOCIATIONS_CONFIG]: {
61-
type: 'object',
62-
markdownDescription: nls.localize('associations', 'Configure file associations to languages (e.g. `"*.extension": "html"`). These have precedence over the default associations of the languages installed.'),
63-
additionalProperties: {
64-
type: 'string'
65-
}
66-
}
67-
}
68-
})

0 commit comments

Comments
 (0)