This commit is contained in:
masad-frost 2018-06-09 02:20:15 -07:00
parent 18e09b4100
commit 0a0c14ab03

View file

@ -9,231 +9,231 @@ import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage; import ILanguage = monaco.languages.IMonarchLanguage;
export const conf: IRichLanguageConfiguration = { export const conf: IRichLanguageConfiguration = {
comments: { comments: {
lineComment: ';;', lineComment: ';;',
blockComment: ['(comment', ')'], blockComment: ['(comment', ')'],
}, },
brackets: [['(', ')'], ['{', '}'], ['[', ']']], brackets: [['(', ')'], ['{', '}'], ['[', ']']],
autoClosingPairs: [ autoClosingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
{ open: '[', close: ']' }, { open: '[', close: ']' },
{ open: '(', close: ')' }, { open: '(', close: ')' },
{ open: '"', close: '"' }, { open: '"', close: '"' },
], ],
surroundingPairs: [ surroundingPairs: [
{ open: '{', close: '}' }, { open: '{', close: '}' },
{ open: '[', close: ']' }, { open: '[', close: ']' },
{ open: '(', close: ')' }, { open: '(', close: ')' },
{ open: '"', close: '"' }, { open: '"', close: '"' },
], ],
}; };
export const language = <ILanguage>{ export const language = <ILanguage>{
defaultToken: '', defaultToken: '',
ignoreCase: true, ignoreCase: true,
tokenPostfix: '.clj', tokenPostfix: '.clj',
brackets: [ brackets: [
{ open: '(', close: ')', token: 'delimiter.parenthesis' }, { open: '(', close: ')', token: 'delimiter.parenthesis' },
{ open: '{', close: '}', token: 'delimiter.curly' }, { open: '{', close: '}', token: 'delimiter.curly' },
{ open: '[', close: ']', token: 'delimiter.square' }, { open: '[', close: ']', token: 'delimiter.square' },
], ],
keywords: [ keywords: [
'ns', 'ns',
'ns-unmap', 'ns-unmap',
'create-ns', 'create-ns',
'in-ns', 'in-ns',
'fn', 'fn',
'def', 'def',
'defn', 'defn',
'defmacro', 'defmacro',
'defmulti', 'defmulti',
'defonce', 'defonce',
'require', 'require',
'import', 'import',
'new', 'new',
'refer', 'refer',
'pos', 'pos',
'pos?', 'pos?',
'filter', 'filter',
'map', 'map',
'reduce', 'reduce',
'repeat', 'repeat',
'key', 'key',
'rest', 'rest',
'concat', 'concat',
'into', 'into',
'reverse', 'reverse',
'iterate', 'iterate',
'range', 'range',
'drop', 'drop',
'drop-while', 'drop-while',
'take', 'take',
'take-while', 'take-while',
'neg', 'neg',
'neg?', 'neg?',
'bound-fn', 'bound-fn',
'if', 'if',
'if-not', 'if-not',
'if-let', 'if-let',
'case,', 'case,',
'contains', 'contains',
'conj', 'conj',
'disj', 'disj',
'sort', 'sort',
'get', 'get',
'assoc', 'assoc',
'merge', 'merge',
'keys', 'keys',
'vals', 'vals',
'nth', 'nth',
'first', 'first',
'last', 'last',
'count', 'count',
'contains?', 'contains?',
'cond', 'cond',
'condp', 'condp',
'cond->', 'cond->',
'cond->>', 'cond->>',
'when', 'when',
'while', 'while',
'when-not', 'when-not',
'when-let', 'when-let',
'when-first', 'when-first',
'do', 'do',
'future', 'future',
'comment', 'comment',
'doto', 'doto',
'locking', 'locking',
'proxy', 'proxy',
'println', 'println',
'type', 'type',
'meta', 'meta',
'var', 'var',
'as->', 'as->',
'reify', 'reify',
'deftype', 'deftype',
'defrecord', 'defrecord',
'defprotocol', 'defprotocol',
'extend', 'extend',
'extend-protocol', 'extend-protocol',
'extend-type', 'extend-type',
'specify', 'specify',
'specify!', 'specify!',
'try', 'try',
'catch', 'catch',
'finally', 'finally',
'let', 'let',
'letfn', 'letfn',
'binding', 'binding',
'loop', 'loop',
'for', 'for',
'seq', 'seq',
'doseq', 'doseq',
'dotimes', 'dotimes',
'when-let', 'when-let',
'if-let', 'if-let',
'when-some', 'when-some',
'if-some', 'if-some',
'this-as', 'this-as',
'defmethod', 'defmethod',
'testing', 'testing',
'deftest', 'deftest',
'are', 'are',
'use-fixtures', 'use-fixtures',
'use', 'use',
'remove', 'remove',
'run', 'run',
'run*', 'run*',
'fresh', 'fresh',
'alt!', 'alt!',
'alt!!', 'alt!!',
'go', 'go',
'go-loop', 'go-loop',
'thread', 'thread',
'boolean', 'boolean',
'str', 'str',
], ],
constants: ['true', 'false', 'nil'], constants: ['true', 'false', 'nil'],
operators: [ operators: [
'=', '=',
'not=', 'not=',
'<', '<',
'<=', '<=',
'>', '>',
'>=', '>=',
'and', 'and',
'or', 'or',
'not', 'not',
'inc', 'inc',
'dec', 'dec',
'max', 'max',
'min', 'min',
'rem', 'rem',
'bit-and', 'bit-and',
'bit-or', 'bit-or',
'bit-xor', 'bit-xor',
'bit-not', 'bit-not',
], ],
tokenizer: { tokenizer: {
root: [ root: [
[/0[xX][0-9a-fA-F]+/, 'number.hex'], [/0[xX][0-9a-fA-F]+/, 'number.hex'],
[/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?/, 'number.float'], [/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?/, 'number.float'],
[ [
/(?:\b(?:(ns|def|defn|defn-|defmacro|defmulti|defonce|ns|ns-unmap|fn))(?![\w-]))(\s+)((?:\w|\-|\!|\?)*)/, /(?:\b(?:(ns|def|defn|defn-|defmacro|defmulti|defonce|ns|ns-unmap|fn))(?![\w-]))(\s+)((?:\w|\-|\!|\?)*)/,
['keyword', 'white', 'variable'], ['keyword', 'white', 'variable'],
], ],
[ [
/[a-zA-Z_#][a-zA-Z0-9_\-\?\!\*]*/, /[a-zA-Z_#][a-zA-Z0-9_\-\?\!\*]*/,
{ {
cases: { cases: {
'@keywords': 'keyword', '@keywords': 'keyword',
'@constants': 'constant', '@constants': 'constant',
'@operators': 'operators', '@operators': 'operators',
'@default': 'identifier', '@default': 'identifier',
}, },
}, },
], ],
[/\/#"(?:\.|(?:\")|[^""\n])*"\/g/, 'regexp'], [/\/#"(?:\.|(?:\")|[^""\n])*"\/g/, 'regexp'],
{ include: '@whitespace' }, { include: '@whitespace' },
{ include: '@strings' }, { include: '@strings' },
], ],
comment: [ comment: [
[/[^comment\(\)]+/, 'comment'], [/[^comment\(\)]+/, 'comment'],
[/\(comment/, 'comment', '@push'], [/\(comment/, 'comment', '@push'],
[/\)/, 'comment', '@pop'], [/\)/, 'comment', '@pop'],
[/[comment\(\)]/, 'comment'], [/[comment\(\)]/, 'comment'],
], ],
whitespace: [ whitespace: [
[/[ \t\r\n]+/, 'white'], [/[ \t\r\n]+/, 'white'],
[/\(comment/, 'comment', '@comment'], [/\(comment/, 'comment', '@comment'],
[/;;.*$/, 'comment'], [/;;.*$/, 'comment'],
], ],
strings: [ strings: [
[/"$/, 'string', '@popall'], [/"$/, 'string', '@popall'],
[/"(?=.)/, 'string', '@multiLineString'], [/"(?=.)/, 'string', '@multiLineString'],
], ],
multiLineString: [ multiLineString: [
[/\\./, 'string.escape'], [/\\./, 'string.escape'],
[/"/, 'string', '@popall'], [/"/, 'string', '@popall'],
[/.(?=.*")/, 'string'], [/.(?=.*")/, 'string'],
[/.*\\$/, 'string'], [/.*\\$/, 'string'],
[/.*$/, 'string', '@popall'], [/.*$/, 'string', '@popall'],
], ],
}, },
}; };