hey look a thing
This commit is contained in:
commit
dac0a80d47
12 changed files with 825 additions and 0 deletions
40
grammar.mts
Normal file
40
grammar.mts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import {IRawGrammar} from 'vscode-textmate';
|
||||
|
||||
// vscode-textmate doesn't expose anything else so fine we'll do it ourselves
|
||||
|
||||
type AllOptionalWritable<T> = { -readonly [K in keyof T]?: T[K] };
|
||||
export type Overwrite<T, U> = {
|
||||
[K in keyof (T & U)]: K extends keyof U ? U[K]
|
||||
: K extends keyof T ? T[K]
|
||||
: never;
|
||||
};
|
||||
type RemoveLocation<T> = Omit<T, '$vscodeTextmateLocation'>;
|
||||
|
||||
type Cleanup<T, Overrides = unknown> = AllOptionalWritable<
|
||||
RemoveLocation<Overwrite<T, Overrides>>
|
||||
>;
|
||||
|
||||
type IRawRepository = IRawGrammar['repository'];
|
||||
type IRawRule = IRawRepository[string];
|
||||
type IRawCaptures = NonNullable<IRawRule['captures']>;
|
||||
|
||||
export type Captures = Cleanup<IRawCaptures>;
|
||||
export type Rule = Cleanup<IRawRule, {
|
||||
captures: Captures;
|
||||
beginCaptures: Captures;
|
||||
endCaptures: Captures;
|
||||
whileCaptures: Captures;
|
||||
repository: Repository;
|
||||
}>;
|
||||
export type Repository = Cleanup<IRawRepository, {
|
||||
[name: string]: Rule;
|
||||
$self: Rule;
|
||||
$base: Rule;
|
||||
}>;
|
||||
export type Grammar = Cleanup<IRawGrammar, {
|
||||
repository: Repository;
|
||||
patterns: Rule[];
|
||||
injections: {
|
||||
[expression: string]: Rule;
|
||||
};
|
||||
}>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue