RsvimSyn
The Rsvim.syn global object for javascript runtime (editor process).
Example
// Create a alias to 'Rsvim.syn'.
const syn = Rsvim.syn;
Methods
getParserMetadata()
getParserMetadata(name): ParserMetadata;
Get tree-sitter parser metadata by parser name.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The parser's name. |
Returns
It returns all the loaded parser names.
Example
// Get parser metadata by name.
const parserMetadata = Rsvim.syn.getParserMetadata("rust");
Rsvim.cmd.echo(`Rust parser metadata: ${parserMetadata}`);
listParsers()
listParsers(): string[];
List all loaded tree-sitter parsers.
Returns
string[]
It returns all the loaded parser names.
Example
// Print all loaded parser names.
const allParserNames = Rsvim.syn.listParsers();
Rsvim.cmd.echo(`All loaded parsers: ${allParserNames}`);
loadParser()
loadParser(options): Promise<string[]>;
Load tree-sitter parsers.
Parameters
| Parameter | Type | Description |
|---|---|---|
| Load options. |
Returns
Promise<string[]>
It returns all the loaded parser names.
See
Throws
Throws TypeError if options is an invalid option, throws Error if failed to load.
Example
// Load `tree-sitter-c` parser.
const parserNames = await Rsvim.syn.loadParser({grammarPath: "./tree-sitter-c"});
Rsvim.cmd.echo(`Loaded parsers: ${parserNames}`);
loadParserSync()
loadParserSync(options): string[];
Load tree-sitter parsers synchronizely.
Parameters
| Parameter | Type | Description |
|---|---|---|
| Load options. |
Returns
string[]
It returns all the loaded parser names.
See
Throws
Throws TypeError if options is an invalid option, throws Error if failed to load.
Example
// Load `tree-sitter-c` parser synchronizely.
const parserNames = Rsvim.syn.loadParserSync({grammarPath: "./tree-sitter-c"});
Rsvim.cmd.echo(`Loaded parsers: ${parserNames}`);