提交 edecd8bc 编写于 作者: M Martin Aeschlimann

Adopt css to language-configuration

上级 f4a8c7a5
...@@ -54,58 +54,15 @@ export function activate(context: ExtensionContext) { ...@@ -54,58 +54,15 @@ export function activate(context: ExtensionContext) {
context.subscriptions.push(disposable); context.subscriptions.push(disposable);
languages.setLanguageConfiguration('css', { languages.setLanguageConfiguration('css', {
wordPattern: /(#?-?\d*\.\d\w*%?)|(::?[\w-]*(?=[^,{;]*[,{]))|(([@#.!])?[\w-?]+%?|[@#!.])/g, wordPattern: /(#?-?\d*\.\d\w*%?)|(::?[\w-]*(?=[^,{;]*[,{]))|(([@#.!])?[\w-?]+%?|[@#!.])/g
comments: {
blockComment: ['/*', '*/']
},
brackets: [['{', '}'], ['[', ']'], ['(', ')']],
__characterPairSupport: {
autoClosingPairs: [
{ open: '{', close: '}' },
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: '"', close: '"', notIn: ['string'] },
{ open: '\'', close: '\'', notIn: ['string'] }
]
}
}); });
languages.setLanguageConfiguration('less', { languages.setLanguageConfiguration('less', {
wordPattern: /(#?-?\d*\.\d\w*%?)|(::?[\w-]+(?=[^,{;]*[,{]))|(([@#.!])?[\w-?]+%?|[@#!.])/g, wordPattern: /(#?-?\d*\.\d\w*%?)|(::?[\w-]+(?=[^,{;]*[,{]))|(([@#.!])?[\w-?]+%?|[@#!.])/g
comments: {
blockComment: ['/*', '*/'],
lineComment: '//'
},
brackets: [['{', '}'], ['[', ']'], ['(', ')'], ['<', '>']],
__characterPairSupport: {
autoClosingPairs: [
{ open: '"', close: '"', notIn: ['string', 'comment'] },
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
{ open: '{', close: '}', notIn: ['string', 'comment'] },
{ open: '[', close: ']', notIn: ['string', 'comment'] },
{ open: '(', close: ')', notIn: ['string', 'comment'] },
{ open: '<', close: '>', notIn: ['string', 'comment'] },
]
}
}); });
languages.setLanguageConfiguration('scss', { languages.setLanguageConfiguration('scss', {
wordPattern: /(#?-?\d*\.\d\w*%?)|(::?[\w-]*(?=[^,{;]*[,{]))|(([@$#.!])?[\w-?]+%?|[@#!$.])/g, wordPattern: /(#?-?\d*\.\d\w*%?)|(::?[\w-]*(?=[^,{;]*[,{]))|(([@$#.!])?[\w-?]+%?|[@#!$.])/g
comments: {
blockComment: ['/*', '*/'],
lineComment: '//'
},
brackets: [['{', '}'], ['[', ']'], ['(', ')'], ['<', '>']],
__characterPairSupport: {
autoClosingPairs: [
{ open: '"', close: '"', notIn: ['string', 'comment'] },
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
{ open: '{', close: '}', notIn: ['string', 'comment'] },
{ open: '[', close: ']', notIn: ['string', 'comment'] },
{ open: '(', close: ')', notIn: ['string', 'comment'] },
{ open: '<', close: '>', notIn: ['string', 'comment'] },
]
}
}); });
commands.registerCommand('_css.applyCodeAction', applyCodeAction); commands.registerCommand('_css.applyCodeAction', applyCodeAction);
......
{
"comments": {
"blockComment": ["/*", "*/"]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}", "notIn": ["string", "comment"] },
{ "open": "[", "close": "]", "notIn": ["string", "comment"] },
{ "open": "(", "close": ")", "notIn": ["string", "comment"] },
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
\ No newline at end of file
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
"id": "css", "id": "css",
"aliases": ["CSS", "css"], "aliases": ["CSS", "css"],
"extensions": [".css"], "extensions": [".css"],
"mimetypes": ["text/css"] "mimetypes": ["text/css"],
"configuration": "./language-configuration.json"
}], }],
"grammars": [{ "grammars": [{
"language": "css", "language": "css",
......
{
"comments": {
"blockComment": ["/*", "*/"],
"lineComment": "//"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"],
["<", ">"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}", "notIn": ["string", "comment"] },
{ "open": "[", "close": "]", "notIn": ["string", "comment"] },
{ "open": "(", "close": ")", "notIn": ["string", "comment"] },
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["<", ">"]
]
}
\ No newline at end of file
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
"id": "less", "id": "less",
"aliases": ["Less", "less"], "aliases": ["Less", "less"],
"extensions": [".less"], "extensions": [".less"],
"mimetypes": ["text/x-less", "text/less"] "mimetypes": ["text/x-less", "text/less"],
"configuration": "./language-configuration.json"
}], }],
"grammars": [{ "grammars": [{
"language": "less", "language": "less",
......
{
"comments": {
"blockComment": ["/*", "*/"],
"lineComment": "//"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"],
["<", ">"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}", "notIn": ["string", "comment"] },
{ "open": "[", "close": "]", "notIn": ["string", "comment"] },
{ "open": "(", "close": ")", "notIn": ["string", "comment"] },
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["<", ">"]
]
}
\ No newline at end of file
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
"id": "scss", "id": "scss",
"aliases": ["Sass", "scss"], "aliases": ["Sass", "scss"],
"extensions": [".scss"], "extensions": [".scss"],
"mimetypes": ["text/x-scss", "text/scss"] "mimetypes": ["text/x-scss", "text/scss"],
"configuration": "./language-configuration.json"
}], }],
"grammars": [{ "grammars": [{
"language": "scss", "language": "scss",
......
...@@ -9,7 +9,7 @@ import {parse} from 'vs/base/common/json'; ...@@ -9,7 +9,7 @@ import {parse} from 'vs/base/common/json';
import {readFile} from 'vs/base/node/pfs'; import {readFile} from 'vs/base/node/pfs';
import {LanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry'; import {LanguageConfiguration} from 'vs/editor/common/modes/languageConfigurationRegistry';
import {IModeService} from 'vs/editor/common/services/modeService'; import {IModeService} from 'vs/editor/common/services/modeService';
import {IAutoClosingPair} from 'vs/editor/common/modes'; import {IAutoClosingPair, IAutoClosingPairConditional} from 'vs/editor/common/modes';
import {LanguageConfigurationRegistry} from 'vs/editor/common/modes/languageConfigurationRegistry'; import {LanguageConfigurationRegistry} from 'vs/editor/common/modes/languageConfigurationRegistry';
type CharacterPair = [string, string]; type CharacterPair = [string, string];
...@@ -22,8 +22,8 @@ interface ICommentRule { ...@@ -22,8 +22,8 @@ interface ICommentRule {
interface ILanguageConfiguration { interface ILanguageConfiguration {
comments?: ICommentRule; comments?: ICommentRule;
brackets?: CharacterPair[]; brackets?: CharacterPair[];
autoClosingPairs?: CharacterPair[]; autoClosingPairs?: (CharacterPair | IAutoClosingPairConditional)[];
surroundingPairs?: CharacterPair[]; surroundingPairs?: (CharacterPair | IAutoClosingPair)[];
} }
export class LanguageConfigurationFileHandler { export class LanguageConfigurationFileHandler {
...@@ -92,10 +92,12 @@ export class LanguageConfigurationFileHandler { ...@@ -92,10 +92,12 @@ export class LanguageConfigurationFileHandler {
LanguageConfigurationRegistry.register(modeId, richEditConfig); LanguageConfigurationRegistry.register(modeId, richEditConfig);
} }
private _mapCharacterPairs(pairs:CharacterPair[]): IAutoClosingPair[] { private _mapCharacterPairs(pairs: (CharacterPair | IAutoClosingPairConditional)[]): IAutoClosingPairConditional[] {
return pairs.map(pair => { return pairs.map(pair => {
let [open, close] = pair; if (Array.isArray(pair)) {
return { open: open, close: close }; return { open: pair[0], close: pair[1] };
}
return <IAutoClosingPairConditional> pair;
}); });
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册