Skip to content

Commit 185150e

Browse files
feat(textmate): 类型 true / false 标记为类型
1 parent 6ce91c6 commit 185150e

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎packages/textmate/src/grammar.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@ const BUILT_IN_TYPES = [
1818
'any',
1919
'unknown',
2020
'never',
21+
2122
'boolean',
23+
'true',
24+
'false',
25+
2226
'number',
2327
'string',
28+
2429
'record',
2530
'array',
2631
'extern',
2732
'module',
33+
2834
'nil',
2935
];
3036
const DOC_CONSTANT_IDENTIFIER = String.raw`(?:@+\p{XID_Continue}+|\p{Lu}[\p{XID_Continue}]*)`;
@@ -1012,10 +1018,6 @@ export function createMiraScriptDocGrammar(): LanguageRegistration {
10121018
name: 'support.type.builtin.mira',
10131019
match: `${IDENTIFIER_START}(?:${alternatives(BUILT_IN_TYPES)})${IDENTIFIER_END}`,
10141020
},
1015-
{
1016-
name: 'constant.language.boolean.mira',
1017-
match: `${IDENTIFIER_START}(?:true|false)${IDENTIFIER_END}`,
1018-
},
10191021
{ name: 'keyword.operator.type.mira', match: '[&|]' },
10201022
{ name: 'keyword.operator.spread.mira', match: String.raw`\.\.` },
10211023
{ name: 'entity.name.type.mira', match: IDENTIFIER },

‎packages/textmate/tests/grammar/documentation-mode.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import test from 'ava';
22
import { tokenize, expectScope } from '../_engine.ts';
33

4+
test('highlights types', (t) => {
5+
const types = ['boolean', 'true', 'false', 'number', 'string', 'array', 'record', 'extern', 'any', 'nil'];
6+
const tokens = tokenize(types.map((type) => `fn _${type}(v: ${type}) -> ${type}`).join('\n'), 'mirascript-doc');
7+
for (const type of types) {
8+
expectScope(t, tokens, type, 'support.type.builtin.mira');
9+
}
10+
});
11+
412
test('highlights generated documentation syntax', (t) => {
513
const tokens = tokenize(
614
[

0 commit comments

Comments
 (0)